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

Prerendering support for useDeferredValue #27512

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Oct 12, 2023

Based on #27509

Revealing a prerendered tree (hidden -> visible) is considered the same as mounting a brand new tree. So, when an initialValue argument is passed to useDeferredValue, and it's prerendered inside a hidden tree, we should first prerender the initial value.

After the initial value has been prerendered, we switch to prerendering the final one. This is the same sequence that we use when mounting new visible tree. Depending on how much prerendering work has been finished by the time the tree is revealed, we may or may not be able to skip all the way to the final value.

This means we get the benefits of both prerendering and preview states: if we have enough resources to prerender the whole thing, we do that. If we don't, we have a preview state to show for immediate feedback.

@facebook-github-bot facebook-github-bot added the React Core Team Opened by a member of the React Core Team label Oct 12, 2023
@react-sizebot
Copy link

react-sizebot commented Oct 13, 2023

Comparing: b2a68a6...f31fcd1

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 +0.02% 174.91 kB 174.94 kB +0.01% 54.43 kB 54.44 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 177.05 kB 177.06 kB = 55.13 kB 55.12 kB
facebook-www/ReactDOM-prod.classic.js +0.04% 567.06 kB 567.28 kB +0.04% 99.81 kB 99.85 kB
facebook-www/ReactDOM-prod.modern.js +0.04% 550.92 kB 551.14 kB +0.04% 96.90 kB 96.94 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against f31fcd1

hexiaokang

This comment was marked as spam.

@acdlite acdlite force-pushed the udv-prerendering branch 3 times, most recently from ac165dd to f7874f9 Compare October 16, 2023 15:51
Revealing a prerendered tree (hidden -> visible) is considered the same
as mounting a brand new tree. So, when an initialValue argument is
passed to useDeferredValue, and it's prerendered inside a hidden tree,
we should first prerender the initial value.

After the initial value has been prerendered, we switch to prerendering
the final one. This is the same sequence that we use when mounting new
visible tree. Depending on how much prerendering work has been finished
by the time the tree is revealed, we may or may not be able to skip all
the way to the final value.

This means we get the benefits of both prerendering and preview states:
if we have enough resources to prerender the whole thing, we do that.
If we don't, we have a preview state to show for immediate feedback.
@acdlite acdlite merged commit 75c1bd7 into facebook:main Oct 17, 2023
36 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 17, 2023
### Based on #27509

Revealing a prerendered tree (hidden -> visible) is considered the same
as mounting a brand new tree. So, when an initialValue argument is
passed to useDeferredValue, and it's prerendered inside a hidden tree,
we should first prerender the initial value.

After the initial value has been prerendered, we switch to prerendering
the final one. This is the same sequence that we use when mounting new
visible tree. Depending on how much prerendering work has been finished
by the time the tree is revealed, we may or may not be able to skip all
the way to the final value.

This means we get the benefits of both prerendering and preview states:
if we have enough resources to prerender the whole thing, we do that. If
we don't, we have a preview state to show for immediate feedback.

DiffTrain build for [75c1bd7](75c1bd7)
kodiakhq bot pushed a commit to vercel/next.js that referenced this pull request Oct 18, 2023
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
### Based on facebook#27509 

Revealing a prerendered tree (hidden -> visible) is considered the same
as mounting a brand new tree. So, when an initialValue argument is
passed to useDeferredValue, and it's prerendered inside a hidden tree,
we should first prerender the initial value.

After the initial value has been prerendered, we switch to prerendering
the final one. This is the same sequence that we use when mounting new
visible tree. Depending on how much prerendering work has been finished
by the time the tree is revealed, we may or may not be able to skip all
the way to the final value.

This means we get the benefits of both prerendering and preview states:
if we have enough resources to prerender the whole thing, we do that. If
we don't, we have a preview state to show for immediate feedback.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
### Based on #27509

Revealing a prerendered tree (hidden -> visible) is considered the same
as mounting a brand new tree. So, when an initialValue argument is
passed to useDeferredValue, and it's prerendered inside a hidden tree,
we should first prerender the initial value.

After the initial value has been prerendered, we switch to prerendering
the final one. This is the same sequence that we use when mounting new
visible tree. Depending on how much prerendering work has been finished
by the time the tree is revealed, we may or may not be able to skip all
the way to the final value.

This means we get the benefits of both prerendering and preview states:
if we have enough resources to prerender the whole thing, we do that. If
we don't, we have a preview state to show for immediate feedback.

DiffTrain build for commit 75c1bd7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants