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

Fix unmount cleanup of Facets #12

Merged
merged 9 commits into from
Nov 5, 2021
Merged

Fix unmount cleanup of Facets #12

merged 9 commits into from
Nov 5, 2021

Conversation

pirelenito
Copy link
Member

The implementation in @react-facet/dom-fiber wasn't correctly removing all subscriptions of Facets when unmounting.

This wasn't a problem in our original implementation of @react-facet/dom-components, and wasn't apparent in our current production screens (as they don't unmount), but can be quite problematic.

Added some extra unit tests.

I’ve verified that for keyed lists, React does not call removeChild to change the order in a list. It simply calls `insertInContainerBefore`.

More info: https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore:

> If the given node already exists in the document, insertBefore() moves it from its current position to the new position. (That is, it will automatically be removed from its existing parent before appending it to the specified new parent.)
@pirelenito pirelenito marked this pull request as draft November 5, 2021 09:01
@pirelenito pirelenito marked this pull request as ready for review November 5, 2021 09:11
Co-authored-by: Fernando Via Canel <fernando.via@gmail.com>
Copy link
Contributor

@xaviervia xaviervia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

@pirelenito pirelenito merged commit e68f51e into main Nov 5, 2021
@pirelenito pirelenito deleted the fix-unmount-cleanup branch November 5, 2021 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants