Skip to content
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 remount element that only update #31907

Open
Xiaoooyooo opened this issue Dec 25, 2024 · 3 comments
Open

Bug: StrictMode remount element that only update #31907

Xiaoooyooo opened this issue Dec 25, 2024 · 3 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@Xiaoooyooo
Copy link

React version: 19.0.0

Steps To Reproduce

  1. use StrictMode
  2. render a list in any way
  3. change the order of the list

Link to code example: codesandbox

The current behavior

When change the order of the list, the list item unmounted and then mounted, except for the first element.

The expected behavior

It should not remount during the update phase.

I test the same code on react 18, which has no problem.

@Xiaoooyooo Xiaoooyooo added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Dec 25, 2024
@AccoladesIO
Copy link

gotten a solution to this yet?

@JorensM
Copy link

JorensM commented Dec 29, 2024

I think this is the expected behavior. Strict Mode double-renders your components to ensure that they remain pure, and it also calls useState updaters (see last point). I'm not sure if an 'updater' implies providing a value or a function or either though. But just to be clear, StrictMode is only used in development to catch bugs, it is not meant for production.

@Harricpp
Copy link

I think this is the expected behavior. Strict Mode double-renders your components to ensure that they remain pure, and it also calls useState updaters (see last point). I'm not sure if an 'updater' implies providing a value or a function or either though. But just to be clear, StrictMode is only used in development to catch bugs, it is not meant for production.

doesnt imply pretty sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

4 participants