Skip to content

Dispatching at the same time as setState causes two renderings #1912

Open
@mineoka-kento

Description

@mineoka-kento

What version of React, ReactDOM/React Native, Redux, and React Redux are you using?

  • React: 18.0.0
  • ReactDOM:18.0.0
  • Redux Toolkit:1.8.1
  • React Redux:8.0.1

What is the current behavior?

Synchronous calls to dispatch and setState within useEffect will cause separate re-rendering.

Since it may not be possible to check visually, try using the Profiler in the React Developer Tools to see how it works.

https://codesandbox.io/s/brave-dew-cc7p4p?file=/src/features/counter/CounterEditor.tsx

screen-recording_1

What is the expected behavior?

The re-rendering occurs only once.

Which browser and OS are affected by this issue?

Chrome/100.0.4896.127, Windows10

Did this work in previous versions of React Redux?

  • Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions