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 #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 commit b2a68a6.
  • Loading branch information
acdlite committed Oct 17, 2023
1 parent 26e2a44 commit b763135
Show file tree
Hide file tree
Showing 13 changed files with 1,384 additions and 818 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-canary-9abf6fa31-20231017";
var ReactVersion = "18.3.0-canary-b2a68a65c-20231017";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,4 +580,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-9abf6fa31-20231017";
exports.version = "18.3.0-canary-b2a68a65c-20231017";
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-9abf6fa31-20231017";
exports.version = "18.3.0-canary-b2a68a65c-20231017";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9abf6fa31cd7ff4c6e54de75950620e203c59ebf
b2a68a65c84b63ac86930d88ae5c84380cbbdeb6
Loading

0 comments on commit b763135

Please sign in to comment.