Bug: useReducer runs the queued updates with new props
See original GitHub issueReact 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (3 by maintainers)
Top Results From Across the Web
React useReducer ignores state updates if executed fastly?
If the promise is rejected, the rollback is executed, updating the UI to the previous state. What I don't understand is why if...
Read more >Hooks API Reference - React
The setState function is used to update the state. It accepts a new state value and enqueues a re-render of the component. setState(newState);....
Read more >React useReducer Hook ultimate guide - LogRocket Blog
The useReducer Hook is used to store and update states, just like the useState Hook. It accepts a reducer function as its first...
Read more >React State Management With useReducer
Like useState and useContext , useReducer is a new twist on a ... Reducers are functions that help us update state based on...
Read more >React Hooks - A deeper dive featuring useContext and ...
If you're brand new to React hooks, check out the Primer on React Hooks ... YET - just prop smuggling import React, {...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think it’s a bug.
mark.