SIGN IN SIGN UP
facebook / react UNCLAIMED

The library for web and native user interfaces.

0 0 92 JavaScript

useDeferredValue should skip initialValue if it suspends (#27509)

### Based on https://github.com/facebook/react/pull/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.
A
Andrew Clark committed
b2a68a65c84b63ac86930d88ae5c84380cbbdeb6
Parent: 9abf6fa
Committed by GitHub <noreply@github.com> on 10/17/2023, 4:48:11 PM