I have a function open()
in a child component which calls the parent's function open()
through props
, and it could be multiple times in a row.
the parent function contains this line
this.setState({numOpen: (++this.state.numOpen)});
This line works and updates the state at every increment.
But before, this line
this.setState({numOpen: (this.state.numOpen + 1)});
skipped over several increments and was breaking the program.
Does setState get called asynchronously? if not, what could be the reason for it?