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

Removing sibling element causes remount #755

Open
theKashey opened this issue Dec 30, 2017 · 2 comments
Open

Removing sibling element causes remount #755

theKashey opened this issue Dec 30, 2017 · 2 comments

Comments

@theKashey
Copy link
Collaborator

theKashey commented Dec 30, 2017

Having 3 elements:

  • A
  • B
  • C

Removing of C does not cause remount of A and B.
Removing of B causes remount of C.
Removing of A causes remount of B and C.

This is actually native React behaviour - #546 (comment)

Expected behaviour:

Changes done of server side shall not remount still existing components on frontend.
Changes done on clientside shall follow default behaviour.

Current behaviour:

Changes done regardless of origin do follow the default behaviour.

How:

  • We can add key to the all elements without key(in autoWrap).
  • Key could be calculated as typename(proxykey) + counter(+hash from props) .
  • Key shall be calculated on hydrate stage.
  • In runtime we should compare rendered children with a hydrated ones (in autoWrap) - if types does not match - drop the generated keys. The new ones will be calculated on next hot-replace.

Pros:

This is actually the behaviour users expect

Cons:

We continue to deeply hack React.

@gregberge
Copy link
Collaborator

At this time this is not the goal of React Hot Loader to change the behaviour of React. If people want this kind of behaviour they can use "key". Wrapping it with custom key will introduce a lot of bugs for a minimal gain.

I vote NO.

@theKashey
Copy link
Collaborator Author

Maybe, in a bright future, React will change it's behavior :)

@gregberge gregberge removed the v4 label Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants