Course contentsShow
← React
Lesson 1442 of 2,39636. Concurrent ReactFree lesson

What useDeferredValue Does

Understanding useDeferredValue as a way to keep UI responsive by showing stale values while new ones render.

What useDeferredValue Does

You'll learn what useDeferredValue is and how it keeps your UI responsive by showing stale values while new ones render.

The Core Idea

useDeferredValue is a React hook that lets you defer updating a part of your UI. When a value changes rapidly (like a search query), this hook gives you two versions: the "current" urgent value and a "deferred" version that updates less urgently. While React renders the expensive UI for the new value, the deferred value stays at the old value, keeping your interface responsive.

Think of it like reading yesterday's newspaper while waiting for today's edition to arrive. You're still getting information (the stale value), but React is working on the fresh content in the background.

How It Works

You pass a value to useDeferredValue, and it returns a version that "lags behind." When the original value changes, React first re-renders your component with the old deferred value, keeping the UI responsive. Then, in a lower-priority update (similar to transitions), React re-renders with the new deferred value.

const deferredQuery = useDeferredValue(query);

The key difference from useTransition: with useTransition, you wrap the state setter. With useDeferredValue, you're given a lagging value to use downstream.

When to Use It

Perfect for expensive derived state—like filtering a huge list based on user input. The input updates immediately (stays responsive), but the filtered results use the deferred value and render non-urgently.

Key Takeaway: useDeferredValue returns a "lagging" version of a value, letting React show stale content while rendering the expensive new version in the background—keeping your UI interactive.