setstate in react when a component is in viewportview 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: reactjs update state example
{
hasBeenClicked: false,
currentTheme: 'blue',
}