I would like to ask why my state is not changing when I do an onclick event. I\'ve search a while ago that I need to bind the onclick function in constructor but still the s
setState()
is asynchronous. The best way to verify if the state is updating would be in the componentDidUpdate()
and not to put a console.log(this.state.boardAddModalShow)
after this.setState({ boardAddModalShow: true })
.
according to React Docs
Think of setState() as a request rather than an immediate command to update the component. For better perceived performance, React may delay it, and then update several components in a single pass. React does not guarantee that the state changes are applied immediately