GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Offscreen] Mount/unmount layout effects by acdlite · Pull Request #21386 · react/react

Conversation

@acdlite

@acdlite acdlite commented Apr 29, 2021

Copy link
Copy Markdown
Collaborator

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

NE-SmallTown reacted with eyes emoji
All reactions
  • 👀 1 reaction
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Apr 29, 2021
@sizebot

sizebot commented Apr 29, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: 28625c6...129640c

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 126.00 kB 126.00 kB = 40.41 kB 40.41 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 128.82 kB 128.82 kB = 41.35 kB 41.35 kB
facebook-www/ReactDOM-prod.classic.js +0.06% 406.15 kB 406.41 kB +0.04% 75.12 kB 75.16 kB
facebook-www/ReactDOM-prod.modern.js +0.06% 394.52 kB 394.78 kB +0.04% 73.31 kB 73.34 kB
facebook-www/ReactDOMForked-prod.classic.js +0.06% 406.15 kB 406.41 kB +0.04% 75.13 kB 75.16 kB
facebook-www/ReactIs-prod.classic.js +2.17% 5.72 kB 5.84 kB +1.98% 1.41 kB 1.44 kB
facebook-www/ReactIs-prod.modern.js +2.17% 5.72 kB 5.84 kB +1.98% 1.41 kB 1.44 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/ReactIs-prod.classic.js +2.17% 5.72 kB 5.84 kB +1.98% 1.41 kB 1.44 kB
facebook-www/ReactIs-prod.modern.js +2.17% 5.72 kB 5.84 kB +1.98% 1.41 kB 1.44 kB
oss-stable/react-is/cjs/react-is.production.min.js +1.62% 2.41 kB 2.45 kB +1.62% 0.93 kB 0.94 kB
oss-stable/react-is/umd/react-is.production.min.js +1.58% 2.40 kB 2.44 kB +1.98% 0.96 kB 0.98 kB
oss-experimental/react-is/umd/react-is.production.min.js +1.56% 2.44 kB 2.48 kB +1.33% 0.98 kB 0.99 kB
oss-experimental/react-is/cjs/react-is.production.min.js +1.55% 2.44 kB 2.48 kB +1.60% 0.94 kB 0.96 kB
oss-experimental/react/cjs/react.production.min.js +1.08% 7.48 kB 7.56 kB +0.58% 2.93 kB 2.94 kB
oss-experimental/react/umd/react.profiling.min.js +0.61% 11.32 kB 11.39 kB +0.29% 4.53 kB 4.54 kB
oss-experimental/react/umd/react.production.min.js +0.61% 11.32 kB 11.39 kB +0.29% 4.53 kB 4.54 kB
facebook-react-native/react/cjs/React-prod.js +0.59% 16.56 kB 16.66 kB +0.45% 4.26 kB 4.28 kB
facebook-react-native/react/cjs/React-profiling.js +0.59% 16.56 kB 16.66 kB +0.45% 4.26 kB 4.28 kB
facebook-www/React-prod.modern.js +0.58% 16.72 kB 16.82 kB +0.51% 4.33 kB 4.36 kB
facebook-www/React-profiling.modern.js +0.58% 16.72 kB 16.82 kB +0.51% 4.33 kB 4.36 kB
facebook-www/React-prod.classic.js +0.58% 16.87 kB 16.96 kB +0.43% 4.38 kB 4.40 kB
facebook-www/React-profiling.classic.js +0.58% 16.87 kB 16.96 kB +0.43% 4.38 kB 4.40 kB
oss-experimental/react-is/cjs/react-is.development.js +0.42% 7.93 kB 7.96 kB +0.19% 2.15 kB 2.15 kB
oss-stable/react-is/cjs/react-is.development.js +0.41% 7.96 kB 8.00 kB +0.23% 2.16 kB 2.17 kB
oss-experimental/react-is/umd/react-is.development.js +0.39% 8.52 kB 8.55 kB +0.18% 2.22 kB 2.23 kB
oss-stable/react-is/umd/react-is.development.js +0.39% 8.56 kB 8.59 kB +0.18% 2.24 kB 2.25 kB
facebook-www/ReactIs-dev.modern.js +0.37% 10.01 kB 10.05 kB +0.15% 2.67 kB 2.68 kB
facebook-www/ReactIs-dev.classic.js +0.37% 10.01 kB 10.05 kB +0.19% 2.67 kB 2.68 kB

Generated by 🚫 dangerJS against 129640c

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@acdlite
acdlite force-pushed the offscreen-component-layout-effects branch from 912b9fd to 3633e8d Compare May 7, 2021 15:43
bvaughn
bvaughn reviewed May 8, 2021
View reviewed changes
Comment thread packages/react-reconciler/src/__tests__/ReactOffscreen-test.js Outdated

@bvaughn bvaughn Apr 29, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
it('mounts without layout effects', async () => {
it('mounts without layout effects when hidden', async () => {

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

acdlite reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@acdlite
[Offscreen] Mount/unmount layout effects
bfea047
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.
@acdlite
acdlite force-pushed the offscreen-component-layout-effects branch from 51786ec to f29bd89 Compare June 1, 2021 19:39
rickhanlonii
rickhanlonii approved these changes Jun 1, 2021
View reviewed changes

@rickhanlonii rickhanlonii left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@acdlite
acdlite marked this pull request as ready for review June 1, 2021 19:42
@rickhanlonii @acdlite
Add test starting from hidden
129640c
@acdlite
acdlite force-pushed the offscreen-component-layout-effects branch from f29bd89 to 129640c Compare June 1, 2021 19:45
@acdlite
acdlite merged commit e16d61c into react:master Jun 1, 2021
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Jun 7, 2021
Andrei Shikov @facebook-github-bot
React Native sync for revisions 2d8d133...0eea577
a403e76
Summary:
- **[0eea577](react/react@0eea57724 )**: Fix typo in comment (accumlated → accumulated) ([#21637](react/react#21637)) //<ithinker5>//
- **[0706162](react/react@0706162ba )**: Fix typo in comment (environement → environment) ([#21635](react/react#21635)) //<niexq>//
- **[9d17b56](react/react@9d17b562b )**: Fix typo in comment (satsify → satisfy) ([#21629](react/react#21629)) //<niexq>//
- **[b610fec](react/react@b610fec00 )**: fix comments: expiration time -> lanes ([#21551](react/react#21551)) //<Shannon Feng>//
- **[cc4d24a](react/react@cc4d24ab0 )**: [Fizz] Always call flush() if it exists ([#21625](react/react#21625)) //<Dan Abramov>//
- **[e0d9b28](react/react@e0d9b2899 )**: [Fizz] Minor Fixes for Warning Parity ([#21618](react/react#21618)) //<Sebastian Markbåge>//
- **[1b7b359](react/react@1b7b3592f )**: [Fizz] Implement Component Stacks in DEV for warnings ([#21610](react/react#21610)) //<Sebastian Markbåge>//
- **[39f0074](react/react@39f007489 )**: Make enableSuspenseLayoutEffectSemantics static for www ([#21617](react/react#21617)) //<Brian Vaughn>//
- **[8f37942](react/react@8f3794276 )**: Prepare semver (`latest`) releases in CI ([#21615](react/react#21615)) //<Andrew Clark>//
- **[8b42015](react/react@8b4201535 )**: Devtools: add feature to trigger an error boundary ([#21583](react/react#21583)) //<Bao Pham>//
- **[154a8cf](react/react@154a8cf32 )**: Fix reference to wrong variable //<Andrew Clark>//
- **[6736a38](react/react@6736a38b9 )**: Add single source of truth for package versions ([#21608](react/react#21608)) //<Andrew Clark>//
- **[86715ef](react/react@86715efa2 )**: Resolve the true entry point during tests ([#21505](react/react#21505)) //<Sebastian Markbåge>//
- **[a8a4742](react/react@a8a4742f1 )**: Convert ES6/TypeScript/CoffeeScript Tests to createRoot + act ([#21598](react/react#21598)) //<Sebastian Markbåge>//
- **[1d35589](react/react@1d3558965 )**: Disable deferRenderPhaseUpdateToNextBatch by default ([#21605](react/react#21605)) //<Sebastian Markbåge>//
- **[a896464](react/react@a8964649b )**: Delete an unused field ([#21415](react/react#21415)) //<okmttdhr>//
- **[76f85b3](react/react@76f85b3e5 )**: Expose Fizz in stable builds ([#21602](react/react#21602)) //<Dan Abramov>//
- **[e16d61c](react/react@e16d61c30 )**: [Offscreen] Mount/unmount layout effects ([#21386](react/react#21386)) //<Andrew Clark>//
- **[6309193](react/react@63091939b )**: OSS feature flag updates ([#21597](react/react#21597)) //<Brian Vaughn>//
- **[efbd69b](react/react@efbd69b27 )**:  Define global __WWW__ = true flag during www tests ([#21504](react/react#21504)) //<Sebastian Markbåge>//
- **[28625c6](react/react@28625c6f4 )**: Disable strict effects for legacy roots (again) ([#21591](react/react#21591)) //<Brian Vaughn>//
- **[3c23414](react/react@3c2341416 )**: Update jest to v26 ([#21574](react/react#21574)) //<Sebastian Silbermann>//
- **[0d493dc](react/react@0d493dcda )**: Removed _debugID field from Fiber - Issue #21558 ([#21570](react/react#21570)) //<Pulkit Sharma>//
- **[7841d06](react/react@7841d0695 )**: Enable the updater-tracking feature flag in more builds ([#21567](react/react#21567)) //<Brian Vaughn>//
- **[6405efc](react/react@6405efc36 )**: Enabled Profiling feature flags for OSS release ([#21565](react/react#21565)) //<Brian Vaughn>//

Changelog:
[General][Changed] - React Native sync for revisions 2d8d133...0eea577

jest_e2e[run_all_tests]

Reviewed By: bvaughn

Differential Revision: D28932083

fbshipit-source-id: 012c1bfb857ed59d7283334d633f1cce8ec50360
koto pushed a commit to koto/react that referenced this pull request Jun 15, 2021
@acdlite @rickhanlonii @koto
[Offscreen] Mount/unmount layout effects (react#21386)
f774c2b
* [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]>
This was referenced Jun 16, 2021
Bug: Layout effects don't re-fire in 18 on Suspense re-showing #21676
Closed
Fix for failed Suspense layout semantics #21694
Merged
@Andarist Andarist mentioned this pull request May 23, 2023
Bug: useInsertionEffect() cleanup function does not fire if a component is wrapped in React.lazy #26670
Closed
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
@acdlite @rickhanlonii
[Offscreen] Mount/unmount layout effects (react#21386)
09067cd
* [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]>
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@acdlite @rickhanlonii
[Offscreen] Mount/unmount layout effects (react#21386)
c67b1e7
* [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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers
@bvaughn bvaughn bvaughn left review comments
@rickhanlonii rickhanlonii rickhanlonii approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@acdlite @sizebot @bvaughn @rickhanlonii @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.