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

Reconcile Call component children with current #11979

Merged
merged 2 commits into from
Jan 7, 2018
Merged

Reconcile Call component children with current #11979

merged 2 commits into from
Jan 7, 2018

Conversation

rmhartog
Copy link
Contributor

@rmhartog rmhartog commented Jan 6, 2018

Solves the issue occurring in #11955. Because the workInProgress.stateNode was used instead of current.stateNode, some Fibers were being deleted twice, causing an invalid state.

The implementation of updateCallComponent is now also closer to reconcileChildrenAtExpirationTime.

@rmhartog
Copy link
Contributor Author

rmhartog commented Jan 6, 2018

I'm also wondering if the second argument of mountChildFibers should be null:

if (current === null) {
workInProgress.stateNode = mountChildFibers(
workInProgress,
workInProgress.stateNode,
nextChildren,
renderExpirationTime,
);
} else {

same as in reconcileChildrenAtExpirationTime?
if (current === null) {
// If this is a fresh new component that hasn't been rendered yet, we
// won't update its child set by applying minimal side-effects. Instead,
// we will add them all to the child before it gets rendered. That means
// we can optimize this reconciliation pass by not tracking side-effects.
workInProgress.child = mountChildFibers(
workInProgress,
null,
nextChildren,
renderExpirationTime,
);
} else {

If so, perhaps it's possible to swap child and stateNode, call reconcileChildrenAtExpirationTime and swap them back, to avoid the 'fork' from getting out of sync in the future. It may hurt readability though, so I'm not too sure about that idea.

Perhaps @gaearon or @sebmarkbage could comment on that?

@gaearon
Copy link
Collaborator

gaearon commented Jan 7, 2018

Nice, mind adding a test that would previously throw but now passes?

@rmhartog
Copy link
Contributor Author

rmhartog commented Jan 7, 2018

Will do!

@gaearon
Copy link
Collaborator

gaearon commented Jan 7, 2018

Seeing that you just dug into the reconciler code for the first time, how was your experience? What do you wish was more documented, what was most confusing etc.

@rmhartog
Copy link
Contributor Author

rmhartog commented Jan 7, 2018

Added a test for un- and remounting behaviour.

I limited myself to the parts of the reconciler that related to the calls and returns. Once I understood the relevant fields and structure of Fiber, and added some log statements throughout, the process started to fall into place.

What was most unclear to me is the status of some of the TODO's I ran into, perhaps linking to an issue which contains more context could be useful, such as:

// Currently assumed to be a continuation and therefore is a
// fiber already.
// TODO: The yield system is currently broken for updates in some
// cases. The reified yield stores a fiber, but we don't know which
// fiber that is; the current or a workInProgress? When the
// continuation gets rendered here we don't know if we can reuse that
// fiber or if we need to clone it. There is probably a clever way to
// restructure this.

// TODO: When bailing out, we might need to return the stateNode instead
// of the child. To check it for work.
// return bailoutOnAlreadyFinishedWork(current, workInProgress);

@gaearon
Copy link
Collaborator

gaearon commented Jan 7, 2018

Hmm good finds. I think some (both?) of these might be outdated and no longer apply.

@gaearon gaearon merged commit 08c86dd into facebook:master Jan 7, 2018
@rmhartog rmhartog deleted the reconcile-call-with-current branch January 8, 2018 09:06
ManasJayanth pushed a commit to ManasJayanth/react that referenced this pull request Jan 12, 2018
* Add test for un- and remounting children of Call

* Reconcile Call component children with `current`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants