Skip to content

Bug: infinite re-renders when queueing state updates via promises during render #33489

Open
@mjesun

Description

@mjesun

React version: 18.3.1

Steps To Reproduce

  1. Created a sandbox to illustrate the issue.
  2. Open and it "trigger".
  3. Check the console. 100 renders are scheduled after hitting trigger, despite setState sets the same value.

The current behavior

  • You will see more than 100 re-renders until we stop it, otherwise it would indefinitely run.

  • This does not happen on React 17, React 18 with legacy root and React 19 (at least in the sandbox, could be due to auto-optimization of the component via the compiler). Happens in all React 18 versions.

The expected behavior

  • Calling setState with the same value already set, even in an asynchronous promise, should not re-trigger the render of the component, even if the operation of updating the state asynchronously within a component is not officially supported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions