Combining with memo for Maximum Benefit
You'll learn how to prevent wasted renders of expensive components by wrapping them in React.memo when they receive deferred values.
The Problem: Deferred Values Still Cause Renders
When you use useDeferredValue, React intentionally re-renders your component with the old (deferred) value first, then again with the new value. If your expensive component receives that deferred value as a prop, it will re-render twice — even when the deferred value hasn't actually changed yet.
This is where React.memo becomes your best friend.
The Solution: Skip Unnecessary Renders
By wrapping your expensive component in React.memo, you tell React: "Only re-render this component if its props have actually changed." When the deferred value is still the old value, memo prevents the expensive component from re-rendering at all.
The pattern:
const ExpensiveList = memo(function ExpensiveList({ items }) {
// Heavy rendering logic here
return <div>{/* render items */}</div>;
});
function SearchPage() {
const [query, setQuery] = useState('');
const deferredQuery = useDeferredValue(query);
// ExpensiveList only re-renders when deferredQuery actually changes
return <ExpensiveList items={filterItems(deferredQuery)} />;
}
Without memo, ExpensiveList would re-render on every keystroke. With memo, it skips renders while deferredQuery stays the same, then renders once when it finally updates.
Think of it like this: useDeferredValue controls when updates happen, while memo controls whether they happen. Together, they're like a one-two punch against performance bottlenecks.
Key Takeaway: Always wrap components receiving deferred values in React.memo to skip redundant renders when the deferred value hasn't changed — this is where the real performance wins come from.