From React’s documentation:
setState()
does not immediately mutatethis.state
but creates a
pending state transition. Accessingthis.state
after calling this
method can potentially return the existing value. There is no
guarantee of synchronous operation of calls tosetState
and calls may
be batched for performance gains.
If you want a function to be executed after the state change occurs, pass it in as a callback.
this.setState({value: event.target.value}, function () {
console.log(this.state.value);
});
You may Also Like:
None found