-
Notifications
You must be signed in to change notification settings - Fork 48k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: StrictMode
reruns effects when a child is moved in an array
#32561
Comments
I did run some tests ,
I hope This Helps ❤️ |
I think this proves it is a bug as the fix you suggest is explicitly called out in the React docs as a pitfall because it creates unstable element-key references: https://react.dev/learn/rendering-lists#why-does-react-need-keys If you dig into |
Encounter the same issue. We have a Drag and drop list; With React18 - the effect are not rerun - key is set to a static ID comming from API. React 18 behavior: output.webmReact 19 behavior: output2.webm |
With strict mode on in React 19, when a keyed React element is moved in an array its effects are rerun, even if they have no dependencies. The same behavior is not done for elements that stay in place. This is different from React 18 where moving an element did not trigger rerunning effects.
I would like confirmation if this is intended or a bug, but I did not see it documented so I assume it is a bug.
React version: 19.0.10
Steps To Reproduce
Here is a repro in React 19: https://stackblitz.com/edit/react-ts-qmpiwmru?file=App.tsx,index.tsx
And the same in React 18: https://stackblitz.com/edit/react-ts-pzgjq9ay?file=App.tsx
The current behavior
All effects are rerun when a keyed React element is moved in a child array.
The expected behavior
No effects are run, like React 18.
The text was updated successfully, but these errors were encountered: