react: Bug: useReducer runs the queued updates with new props
React version: 16.8.0
Steps To Reproduce
Link to code example: https://codesandbox.io/s/usereducer-wfcmq Link to codesandbox.
The current behavior
Initially step is 0. So for every step react does not rerender due to this https://github.com/facebook/react/blob/master/packages/react-reconciler/src/ReactFiberHooks.js#L1347. But state updates are queued. So when step changes all the state updates are done and hence creates a bug by adding the new step prop.
https://overreacted.io/a-complete-guide-to-useeffect/#why-usereducer-is-the-cheat-mode-of-hooks
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (2 by maintainers)
I think it’s a bug.