Skip to content

Bug: useReducer runs the queued updates with new props #17953

Closed
@a-c-sreedhar-reddy

Description

@a-c-sreedhar-reddy

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions