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

The Basic useDeferredValue Pattern

Using useDeferredValue to defer expensive derived state while keeping inputs responsive.

The Basic useDeferredValue Pattern

You'll learn how to use useDeferredValue to keep inputs responsive while deferring expensive computations.

The Core Pattern

useDeferredValue takes a value and returns a "deferred" version of it. When the original value changes, React updates your UI in two passes:

  1. First pass: Re-render immediately with the old deferred value (keeping the UI responsive)
  2. Second pass: Re-render with the new deferred value in the background (as a low-priority update)

This is perfect when you have an input that drives expensive rendering—like filtering a huge list.

The Basic Syntax

import { useState, useDeferredValue } from 'react';

function SearchPage() {
  const [query, setQuery] = useState('');
  const deferredQuery = useDeferredValue(query);

  return (
    <>
      <input 
        value={query} 
        onChange={e => setQuery(e.target.value)} 
      />
      <ExpensiveList searchQuery={deferredQuery} />
    </>
  );
}

Here's what happens: typing updates query instantly (the input stays responsive), but deferredQuery lags behind. ExpensiveList renders with slightly stale data during typing, then catches up when you pause.

The Mental Model

Think of it like autocomplete with a delay—but smarter. Instead of an arbitrary timeout, React defers the heavy work only when necessary to keep interactions smooth. The input always updates immediately; the expensive derived state follows when the browser has idle time.

Key Takeaway: The basic useDeferredValue pattern is wrapping a state value, then passing the deferred version to expensive child components, allowing urgent updates (like typing) to stay responsive while heavy rendering happens in the background.