useDeferredValue and stale UI
useDeferredValue lets one part of the UI lag behind the latest value.
import { useDeferredValue, useState } from 'react';
function SearchPage() {
const [query, setQuery] = useState('');
const deferredQuery = useDeferredValue(query);
return (
<>
<input
value={query}
onChange={(event) => setQuery(event.target.value)}
/>
<SearchResults query={deferredQuery} />
</>
);
}
What the input and immediate UI need now.
What slower or suspending UI may temporarily keep using.
How the catch-up render worksโ
Suppose query changes from react to reacts.
The canonical value updates immediately. The dependent subtree is allowed to catch up in background work.
Background rendering is interruptibleโ
If the user keeps typing, React can abandon an obsolete deferred render and restart toward the latest value.
There is no fixed delayโ
useDeferredValue is not a debounce. React does not wait a fixed 200ms or 500ms timer. It starts background rendering after urgent work and can interrupt that render when more urgent work arrives.
It does not debounce requestsโ
const deferredQuery = useDeferredValue(query);
This does not guarantee fewer network requests. If your data layer starts a request for every query value, you may still get one request per keystroke.
Stale content with Suspenseโ
const deferredQuery = useDeferredValue(query);
const isStale = query !== deferredQuery;
return (
<Suspense fallback={<ResultsSkeleton />}>
<div style={{ opacity: isStale ? 0.5 : 1 }}>
<SearchResults query={deferredQuery} />
</div>
</Suspense>
);
Stale UI should be communicated through dimming, aria-busy, subtle progress, or another appropriate indicator.
initialValueโ
Current React supports an optional initial value:
const deferredValue = useDeferredValue(value, initialValue);
If supplied, initialValue can be used during the initial render before React catches up in the background. Without it, the initial render uses value because there is no previous version to preserve.
Use this carefully: an inappropriate initial value can briefly represent UI that never existed as canonical state.
Stable value identity mattersโ
Primitive values are straightforward.
const deferredQuery = useDeferredValue(query);
Avoid creating a brand-new object during every render just to defer it:
const deferredFilters = useDeferredValue({ query, sort });
That object is different every render. Prefer stable structured values when identity matters.
const filters = useMemo(() => ({ query, sort }), [query, sort]);
const deferredFilters = useDeferredValue(filters);
React compares values using Object.is semantics when deciding whether background catch-up work is needed.
Effects wait for the deferred render to commitโ
Inside a Transitionโ
If an update is already inside a Transition, useDeferredValue does not need to create a separate deferred render for that same value. The update is already non-urgent.
Do not mechanically combine every concurrency API; choose the smallest one that expresses the intended priority relationship.
useDeferredValue vs useTransitionโ
startTransition(() => {
setTab(nextTab);
});
const deferredQuery = useDeferredValue(query);
Deferred rendering vs debounceโ
You can use both when you need both request timing control and rendering responsiveness.
Deferred rendering does not make slow UI cheapโ
If the slow child still re-renders urgently even while its deferred prop is unchanged, component boundaries or memo may still matter.
const SlowList = memo(function SlowList({ text }) {
// expensive rendering
});
const deferredText = useDeferredValue(text);
return <SlowList text={deferredText} />;
Concurrency changes priority; profiling and architecture still decide cost.
Production data-table patternโ
When not to deferโ
Do not defer values when lag would be confusing or unsafe, for example direct drag position, checkbox state, current accessibility state, or values immediately required for a destructive confirmation.
Common mistakesโ
- treating the deferred value as canonical state;
- expecting fewer server requests automatically;
- hiding that visible content is stale;
- passing unstable objects created during every render;
- assuming deferral replaces memoization or architecture work.
Debugging checklistโ
- Is urgent state updating immediately?
- Does the expensive subtree actually receive the deferred value?
- Are unstable identities causing extra background work?
- Does Suspense preserve old deferred content as expected?
- Are requests still firing too often?
- Is stale UI visibly communicated?
- Is stale UI actually acceptable for this feature?
Exerciseโ
Build a search page with 5,000 local items. Add artificial render cost, compare urgent rendering to useDeferredValue, memoize the list, show stale feedback, and compare the behavior with a 300ms debounce.
Interview questionsโ
Beginner: What does useDeferredValue return?
Intermediate: Why does it not reduce network requests by itself?
Senior: How would you combine urgent input, deferred results, Suspense, memoization, request cancellation, and stale-state UX in production search?
Summaryโ
Referencesโ
- https://react.dev/reference/react/useDeferredValue
- https://react.dev/reference/react/Suspense
- https://react.dev/reference/react/useTransition
Nextโ
Next, connect these APIs to React's broader concurrent rendering mental model.