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?] componentWillUnmount calls not called before owning parent's. #4752

Closed
trusktr opened this issue Sep 1, 2015 · 2 comments
Closed

Comments

@trusktr
Copy link

trusktr commented Sep 1, 2015

For details, see here: pilwon/react-famous#21

Basically, it seems that when a component will be unmounted, it's componentWillUnmount method needs to be called after those of the elements that it owns.

This issue is related to #2789 and should probably be addressed (although the part about mixins can be ignored).

@trusktr
Copy link
Author

trusktr commented Sep 1, 2015

By console.logging inside of componentWillUnmount methods of all my components, I can indeed see that the calls happen in pre-order, but IMHO they should happen in post-order.

I haven't verified, but as reasoned in #2789, it makes sense to do the mounting in reverse of the unmounting (pre-order).

@sophiebits
Copy link
Collaborator

This is intentional. componentDidMount of a parent gets called after componentDidMount of its children, so you know your children are fully initialized before using them. Likewise, componentWillUnmount is called before children (the reverse of componentDidMount) so that you have a chance to reverse anything that you might have done in componentDidMount.

For react-famous, probably an alternate rendering backend is more appropriate, more like react-art or react-canvas or react-native but we don't yet have a good supported way to do that. (Unlike the lifecycle method, that would allow you to do the actual unmounting in the order you prefer.) Your solution of removing the children from the parent sounds pretty reasonable though.

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

No branches or pull requests

2 participants