-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Add Suspense Boundary Context (and unstable_avoidThisFallback) #15578
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sebmarkbage
changed the title
Add Suspense Boundary Context
Add Suspense Boundary Context (and unstable_avoidThisFallback)
May 7, 2019
ReactDOM: size: 🔺+0.3%, gzip: 🔺+0.3% Details of bundled changes.Comparing: f9e60c8...b415837 react-dom
react-art
react-native-renderer
react-test-renderer
react-reconciler
Generated by 🚫 dangerJS |
acdlite
reviewed
May 7, 2019
acdlite
reviewed
May 7, 2019
acdlite
approved these changes
May 7, 2019
acdlite
reviewed
May 7, 2019
// We can use this to determine if it is desirable to trigger a fallback at | ||
// the parent. If not, then we might need to trigger undesirable boundaries | ||
// and/or suspend the commit to avoid hiding the parent content. | ||
export const InvisibleParentSuspenseContext: SubtreeSuspenseContext = 0b01; |
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.
I find this name confusing but don't have a better suggestion
GCC doesn't optimize this case. Saves us a couple of bytes and is shorter.
sebmarkbage
force-pushed
the
preferprevious
branch
from
May 8, 2019 00:53
1f52c96
to
b415837
Compare
This was referenced May 19, 2024
Open
[Snyk] Upgrade: react, react-dom
https-quantumblockchainai-atlassian-net/edgio-astro-ssr-example#651
Open
[Snyk] Upgrade: react, react-dom
https-quantumblockchainai-atlassian-net/edgio-astro-ssr-example#655
Open
[Snyk] Upgrade: react, react-dom
https-quantumblockchainai-atlassian-net/edgio-astro-ssr-example#659
Open
This was referenced Nov 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds a new context for Suspense boundaries. This will be used to implement longer suspense in cases it's undesirable to show a certain fallbacks state and SuspenseList.
The context is a bitmask split into two parts. A shallow part that only applies to the direct suspense boundaries below. A subtree part that applies to the entire subtree deeply. Currently there are only two flags but I expect we'll need more in the future. I already have a couple of ideas (like tagging dehydrated boundaries and optimizations for suspense list).
The interesting case that this PR models is the difference if suspense happens in a tree that is already showing its content on the screen or if the content of the current suspense boundary is invisible.
If the current suspense boundary is showing content, then switching to the fallback would hide that content. This is always undesirable. In a follow up, I will add an option to suspend the commit for longer in this case. This will kick in regardless if there is a
unstable_avoidThisFallback
boundary or not. Having one of these avoided boundaries is completely optional.However, in the case where we cannot suspend the commit for longer (e.g. because there was no busy spinner or we're in a sync mode), the flag
unstable_avoidThisFallback
can be used as a back up boundary to avoid completely falling back to the outer most boundary. It's never a good idea to have one so I'm not sure we'll actually want to keep this API but this lets us play with it. I didn't bother adding too many tests for it.During initial render (or if the tree was previously hidden) then a
unstable_avoidThisFallback
boundary behaves as if there was no boundary there at all. The outer one catches it.