react toggle state code example
Example 1: toggle boolean state react
this.setState(prevState => ({
check: !prevState.check
}));
Example 2: react toggle state
this.setState(prevState => ({
iover: !prevState.iover
}));
Example 3: react toggle state
this.setState(prevState => ({
iover: prevState.iover === 'hide' ? 'show' : 'hide'
}));