Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
setState({ value: false });
setState({ value: true });
// After React updates the state, what will `value` be?
// In other words, if you follow the above code with something like...
setTimeout(() => {
setState(prevState => {
console.log('The value is', prevState.value);
// What will be logged here?
// Is it always `true`, or could it be `false`?
});
// Give React sufficient time to update the state from the first two calls
}, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.