Open
Description
React version: 18.3.1
Steps To Reproduce
- Created a sandbox to illustrate the issue.
- Open and it "trigger".
- 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.