Open
Description
Using the react Example given for useOptimistic hook in docs, an update in state passed to the hook should directly reset the optimisticState in one render.
Instead
- It calls the updaterFn first, updates the optimisticState using new state and optimisticValue during one render cycle
resets optimisticState with new State in another render cycle. - As a result, both the new state and optimisticValue is rendered. Tried this in 20x slowdown
React.19.issue.mov
React version: 19
Steps To Reproduce
- Throttle CPU to 20x slowdown
- Type some input in text box and press submit
- See that the optimistic state is displayed and then it is pushed down for an instant along with the new state
- Check console logs

Link to code example:
The current behavior
When new state is passed to useOptimistic,
- It updates optimisticState by calling updaterFn with new state and optimisticValue
- Component is rendered using this optimisticState (incorrect one)
- Another update to optimisticState is done by resetting it to the new state
- Component is rendered using this new optimisticState (correct one)
The expected behavior
When new state is passed to useOptimistic, it should directly reset the optimisticState without calling the updater Fn