Bug: useState hook not updating state correctly in async functions
Bug Description
When using useState hook inside an async function, the state doesn't update correctly after awaiting a promise.
Steps To Reproduce
- Create a component with useState
- Create an async function that awaits a promise
- Try to update state after the await
- State shows stale value
Expected Behavior
State should update correctly after async operations
Actual Behavior
State retains old value
React version: 19.0.0
It doesn't look like this bug report has enough info for one of us to reproduce it.
Please provide a CodeSandbox (https://react.new), or a link to a repository on GitHub.
Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve
This is not a React bug.
When you await inside a function, you create a new continuation, and any variables captured earlier (including state values) remain the old value. This is expected JavaScript behavior, not a React defect.
React will update state — but your async function will still “see” the old state if you reference stale closures.
✅ Use Functional State Updates
Functional updates ensure your state is always fresh, even after await:
const [count, setCount] = useState(0);
async function handleClick() {
await someAsyncTask();
setCount(prev => prev + 1); // always correct
}
This avoids stale closures entirely.