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

Unexpected interleaving of subtree/parent lifecycle methods #7827

Closed
vsiao opened this issue Sep 28, 2016 · 2 comments
Closed

Unexpected interleaving of subtree/parent lifecycle methods #7827

vsiao opened this issue Sep 28, 2016 · 2 comments

Comments

@vsiao
Copy link
Contributor

vsiao commented Sep 28, 2016

Repro: https://jsfiddle.net/5t5ua47c/
In the example, a click handler in the subtree queues an update for both the the subtree and parent components, with the following ordering of lifecycle methods:

parent will update
> child will update
>> subtree will update
> child did update
parent did update
>> subtree did update

If the parent component unmounts the subtree in componentDidUpdate this will cause the subtree to be unmounted by the time that its componentDidUpdate method is called (https://jsfiddle.net/v5fk4xvx/1/):

parent will update
> child will update
>> subtree will update
> child did update
parent did update (unmount subtree)
>> subtree will unmount
>> subtree did update

What is the expected behavior?

Probably this:

parent will update
> child will update
>> subtree will update
> child did update
>> subtree did update
parent did update
@gaearon
Copy link
Collaborator

gaearon commented Oct 27, 2016

This looks like a bug to me. I'm not sure it's high priority since we're concentrating on Fiber now (#6170) but it would be great if you could turn this into a failing test case.

@gaearon
Copy link
Collaborator

gaearon commented Oct 4, 2017

unstable_renderSubtreeIntoContainer was pretty broken in general.

Since React 16, we now offer a first-class portal API that replaces it and doesn’t suffer from the interleaving issues.

@gaearon gaearon closed this as completed Oct 4, 2017
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