state management in react code example
Example 1: setstate react js
constructor(props) {
super(props);
this.state = {
isActive: true,
};
}
checkStatus = () => {
this.setState({ // use this function
'isActive' : !this.state.isActive,
});
}
Example 2: react state management
Redux is overused. Don't use it.
Props, Component composition and useContext/useReducer is enough for 95% of the apps.