In the function propagateContextChanges and propagateContextChange_eager, the workInProgress.child.return is changed in the beginning, but it is not restore in the end.
In case of propagateContextChanges:
function propagateContextChanges<T>(
workInProgress: Fiber,
contexts: Array<any>,
renderLanes: Lanes,
forcePropagateEntireTree: boolean,
): void {
// Only used by lazy implemenation
if (!enableLazyContextPropagation) {
return;
}
let fiber = workInProgress.child;
if (fiber !== null) {
// caution: before next line , fiber.return is workInProgress.alternate
fiber.return = workInProgress;
// after this line, fiber.return = workInProgress
}
// ... omit the other code
// but in the end, there is no code to restore the workInProgress.child.return
// maybe like this:
workInProgress.child.return = workInProgress.alternate;
}
I think the workInProgress.child is same as workInProgress.alternate.child at this time.
If the workInProgress.child.return not restore, though the workInProgress tree is no difference , but maybe the current tree is broken?
I'm confused about it some days, could anyone explain it?
This is the code from
ReactFiberNewContext.old.js
https://github.com/facebook/react/blob/19092ac8c354b92c2e0e27b73f391571ad452505/packages/react-reconciler/src/ReactFiberNewContext.old.js#L319-L333
In the function
propagateContextChanges
andpropagateContextChange_eager
, theworkInProgress.child.return
is changed in the beginning, but it is not restore in the end.In case of
propagateContextChanges
:I think the
workInProgress.child
is same asworkInProgress.alternate.child
at this time.If the
workInProgress.child.return
not restore, though theworkInProgress tree
is no difference , but maybe thecurrent tree
is broken?I'm confused about it some days, could anyone explain it?