dillon1000/react
Commit
Browse files [Offscreen] Mount/unmount layout effects (#21386)
* [Offscreen] Mount/unmount layout effects Exposes the Offscreen component type and implements basic support for mount/unmounting layout effects when the visibility is toggled. Mostly it works the same way as hidden Suspense trees, which use the same internal fiber type. I had to add an extra bailout, though, that doesn't apply to the Suspense case but does apply to Offscreen components: a hidden Offscreen tree will eventually render at low priority, and when we it does, its `subtreeTag` will have effects scheduled on it. So I added a check to the layout phase where, if the subtree is hidden, we skip over the subtree entirely. An alternate design would be to clear the subtree flags in the render phase, but I prefer doing it this way since it's harder to mess up. We also need an API to enable the same thing for passive effects. This is not yet implemented. * Add test starting from hidden Co-authored-by: Rick Hanlon <[email protected]>
Changed paths9 files
First-parent comparisonpackages/react-reconciler/src/ReactFiberCommitWork.new.js ModifiedM packages/react-reconciler/src/ReactFiberCommitWork.old.js ModifiedM packages/react-reconciler/src/__tests__/ReactOffscreen-test.js ModifiedM packages/react/index.classic.fb.js ModifiedM packages/react/index.experimental.js ModifiedM packages/react/index.js ModifiedM packages/react/index.modern.fb.js ModifiedM packages/react/src/React.js ModifiedM packages/shared/isValidElementType.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…