componentDidMount() { const incFunc = () => this.setState( {counter: this.state.counter + 1}); this.timerID = setInterval(incFunc, 2 * 1000); } calender code example
Example: setstate react js
constructor(props) {
super(props);
this.state = {
isActive: true,
};
}
checkStatus = () => {
this.setState({ // use this function
'isActive' : !this.state.isActive,
});
}