This maybe a repetitive question but I am still not able to figure out why setState is not able to toggle boolean values? Here are the functions:
constructor(props){
super(props)
this.state = {
isPlaying: false
}
}
playButtonClicked = () => {
this.setState((prevState) => ({
isPlaying: !prevState.isPlaying
}))
console.log("updating state....state is="+this.isPlaying) // Its printing undefined
this.togglePlayPause();
}
Here's the div:
<button id="play-pause" onClick={this.playButtonClicked}></button>
Please let me know if you find the mistake. Thanks in advance.