useDeferredValue Didn't Fix My Laggy Input. React.memo Did.
A teammate pinged me about our internal dashboard last week. The search box felt sticky. Two thousand rows, a scoring function that took about 45ms to run over the whole set, and every keystroke waited for it to finish. I told him to put useDeferredValue on the query and get on with his day.
Then I went and measured it, because I have been burned before by advice that sounds right. Mine was half wrong. The deferred value did not make the page faster. It moved the slow part somewhere less annoying.
Six versions of a laggy input
I built the same search box six ways and typed into each with real key events: React 19.3.1 production build, Chrome 157 headless, driven over the debugging protocol, with Chrome's Event Timing API reporting each keystroke from event to next paint. Same 2,000 rows and the same filter every time. Two runs each, numbers held steady.
Doing nothing gave a keystroke of 48 to 64ms, and the character took 41 to 63ms to settle. That's the sticky feeling, quantified. Over five keystrokes my 8ms probe caught four separate gaps of roughly 60ms on the main thread.
Now the version I recommended. useDeferredValue on the query, list not memoized: keystroke still 40 to 64ms. The list itself got worse, 78 to 104ms behind the keyboard instead of 40 to 63. And the filter ran twice per keystroke instead of once.
Why the filter ran twice
Deferring a value does not stop the urgent render, it forces React to do it with the stale copy. A keystroke re-renders the parent, the parent hands the child the old deferred query, and the child recomputes everything for a value that has not changed. Then the background render runs and does it again.
Two passes of a 45ms loop to produce one updated list. My probe timed 400ms of filtering across five keystrokes, where doing nothing measured 260ms.
The memo question decides whether any of this works. Add React.memo and the urgent render bails out, because its prop is a string that did not change:
const MemoList = memo(SlowList)
function Search() {
const [q, setQ] = useState('')
const dq = useDeferredValue(q)
return (
<>
<input value={q} onChange={e => setQ(e.target.value)} />
<MemoList query={dq} />
</>
)
}
With that in place, two of the five keystrokes were too fast for Chrome to report at all, the rest came in at 16 to 24ms, and the character settled in 3 to 17ms. Back to one filter pass per keystroke.
But here is what I did not expect. My probe still caught four blocks of 49 to 65ms in the same window. Deferring had not removed one of them. It rescheduled all four, right after the paint. The keyboard stopped waiting. The browser stayed just as busy.
useTransition with only the list state wrapped behaved the same as the unmemoized deferred version: two filter passes per keystroke, an 83ms block, and a keyboard delay of 37 to 44ms. So the useDeferredValue vs useTransition question was a dud on this workload. Both performed the same. What differs is what you get back: useTransition hands you isPending for a loading hint, though that flag has its own quirks, and useDeferredValue hands you a value you compare yourself. Pick on API shape, not speed.
The version I keep seeing in tutorials, wrapping the input's own setState in startTransition, was the worst of the six. The box took 77 to 103ms to show the character I had just typed. I get why people write it, the code looks symmetric, but the box is the one thing that must never be deferred.
Give React somewhere to stop
Last version, and the only one I would ship. Keep the memo and the deferred value, then split the filter across 20 sibling components. Same total work, a hundred rows each.
const CHUNKS = Array.from({ length: 20 }, (_, i) => [i * 100, i * 100 + 100])
function Chunk({ query, from, to }) {
const rows = scoreRows(query, from, to)
return <>{rows.map(r => <li key={r}>{r}</li>)}</>
}
const ChunkedList = memo(({ query }) => (
<ul>
{CHUNKS.map(([a, b], i) => (
<Chunk key={i} query={query} from={a} to={b} />
))}
</ul>
))
Keystroke 16 to 24ms. Character on the next frame. And one 26ms block in the whole five-keystroke window instead of four of 60.
The reason is boring once you see it. React can pause a background render between components. It cannot pause inside one. My original 45ms loop lived in a single component, so the scheduler had nowhere to breathe. Twenty components of roughly 2ms each gave it twenty places to look up.
What's left in that 26ms is not the loop either. Four times bigger chunks and ten times fewer rendered rows both left the number where it was. That's below the range where typing feels wrong, so I stopped caring.
What you pay for it
The list falls further behind with the chunked version: 45 to 80ms instead of 40 to 63. That is the trade: list freshness for an honest keyboard. It is the right way round, because a delayed list looks like loading and a delayed cursor looks broken.
Then show the delay. q !== dq tells you when the list on screen belongs to an older query. A dimmed wrapper is enough. Skip it and people think the search did nothing.
None of this reduces total work. Every version ran the same 45ms of filtering per keystroke, and the unmemoized ones ran it twice. Scheduling is not optimization. If the filter itself is the problem, your options are still a smaller set, a cheaper match, or a worker.
I keep the chunked list and the memo in Snippet Ark, so I stop rediscovering that the hook was never the fix. The hook says when. The memo and the split say how much of the thread you borrow at once.