Skip to content

Commit

Permalink
useDeferredValue should skip initialValue if it suspends (#27509)
Browse files Browse the repository at this point in the history
### Based on facebook/react#27505

If a parent render spawns a deferred task with useDeferredValue, but the
parent render suspends, we should not wait for the parent render to
complete before attempting to render the final value.

The reason is that the initialValue argument to useDeferredValue is
meant to represent an immediate preview of the final UI. If we can't
render it "immediately", we might as well skip it and go straight to the
"real" value.

This is an improvement over how a userspace implementation of
useDeferredValue would work, because a userspace implementation would
have to wait for the parent task to commit (useEffect) before spawning
the deferred task, creating a waterfall.

DiffTrain build for [b2a68a65c84b63ac86930d88ae5c84380cbbdeb6](facebook/react@b2a68a6)
  • Loading branch information
jerrydev0927 committed Oct 17, 2023
1 parent 647624b commit 82b15d4
Show file tree
Hide file tree
Showing 23 changed files with 2,505 additions and 1,407 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
67cc9ba8789335b9da0838a446137c1be62adbcd
b2a68a65c84b63ac86930d88ae5c84380cbbdeb6
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-classic-b6ac59ca";
var ReactVersion = "18.3.0-www-classic-8c719f5e";

// ATTENTION
// When adding new symbols to this file,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-www-classic-1a677f82";
exports.version = "18.3.0-www-classic-703d13e3";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,4 +579,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-www-modern-a28e1532";
exports.version = "18.3.0-www-modern-eba2410d";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-www-modern-a6764733";
exports.version = "18.3.0-www-modern-f61d9097";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
Loading

0 comments on commit 82b15d4

Please sign in to comment.