Filter large lists in React without blocking user input
Use React 18's useDeferredValue and useTransition to keep inputs responsive during expensive list renders, with code examples and verification steps.
22 Sept 2025, 01:59 UTC

The problem: every keystroke re-renders ten thousand rows
Imagine a search input above a list of 10,000 items. On each keystroke, React updates the query state, runs a filter function, and re-renders the list. On a slow device or a deep component tree, the input itself can lag. The user types faster than the UI can keep up, and the page feels broken even though the code is correct.
The useful takeaway is that you do not have to choose between a responsive input and an up-to-date list. React 18's concurrent features let you update the input immediately while letting the expensive rendering work happen at a lower priority.
useDeferredValue: show the input now, the list later
useDeferredValue accepts a value and returns a copy that React updates lazily. The source state changes immediately, but the deferred copy lags behind until the main thread can afford the work. This is not a timer; React decides when to process the deferred update based on internal priority lanes, which are scheduling units for urgent versus background work.
Here is a minimal example for a React 18 app using createRoot from react-dom/client, which is required for concurrent rendering:
import { useState, useDeferredValue } from 'react';
const ITEMS = Array.from({ length: 10000 }, (_, i) => `Item ${i + 1}`);
export default function SearchList() {
const [query, setQuery] = useState('');
const deferredQuery = useDeferredValue(query);
const filtered = ITEMS.filter((item) =>
item.toLowerCase().includes(deferredQuery.toLowerCase())
);
return (
<>
setQuery(event.target.value)}
placeholder='Search items'
/>
{filtered.map((item) => (
- {item}
))}
);
}
The input binds to query, so the user sees every character instantly. The list renders with deferredQuery, so it may briefly show results for an older query while React finishes filtering. There is no loading flag with this hook; the stale value is the signal.
useTransition: mark a state update as non-urgent
useTransition returns isPending and startTransition. Wrap a state update in startTransition to tell React it can be interrupted by urgent work such as typing or clicking. isPending is true while that transition is waiting, which is useful for a temporary sorting message.
Use this when the state update itself triggers expensive rendering. In this example, changing the sort column re-sorts a large dataset:
import { useState, useTransition, useMemo } from 'react';
const ROWS = Array.from({ length: 12000 }, (_, i) => ({
id: i,
name: `Item ${i + 1}`,
value: Math.random() * 1000,
}));
export default function SortableTable() {
const [sortColumn, setSortColumn] = useState('name');
const [isPending, startTransition] = useTransition();
const sortedRows = useMemo(() => {
return [...ROWS].sort((a, b) => {
if (a[sortColumn] < b[sortColumn]) return -1;
if (a[sortColumn] > b[sortColumn]) return 1;
return 0;
});
}, [sortColumn]);
function handleSort(column) {
startTransition(() => {
setSortColumn(column);
});
}
return (
<>
handleSort('name')}>Sort by name
handleSort('value')}>Sort by value
{isPending && Sorting…}
Name
Value
{sortedRows.map((row) => (
{row.name}
{row.value.toFixed(2)}
))}
);
}
The useMemo ensures the expensive sort only re-runs when sortColumn changes. Wrapping setSortColumn in startTransition lets React pause the sort if the user interacts elsewhere. isPending reflects only updates started with startTransition; it does not track useDeferredValue.
Transitions versus debouncing
| Approach | What it delays | Pending signal | Best for |
|---|---|---|---|
useDeferredValue |
A derived value rendered downstream | None | Input-bound lists and filters |
useTransition |
A state update triggered by an event | isPending |
Sorting, tab switches, optimistic UI |
| Debounce / throttle | The state change itself | None, unless you build it | Reducing API calls or scroll events |
React transitions do not cancel network requests. If your filter triggers a fetch, pair it with AbortController. They also do not guarantee work happens later; if the main thread is idle, React may process the update in the same frame.
Version requirements and legacy mode
These hooks require React 18 or later. To get concurrent deferral, create the root with createRoot from react-dom/client:
import { createRoot } from 'react-dom/client';
import App from './App';
const root = createRoot(document.getElementById('root'));
root.render();
In a legacy root created with ReactDOM.render, the hooks still exist, but they do not defer work. useDeferredValue returns the current value immediately, and updates wrapped in startTransition are treated as urgent. The behavior described here assumes a concurrent root.
Limitations and how to verify
- Do not use these hooks to hide a slow component. Memoize or virtualize expensive lists first.
isPendingis false foruseDeferredValueupdates.- These hooks do not cancel in-flight network requests.
A practical check is to open React DevTools Profiler, record a typing session, and confirm the input update is processed in a high-priority lane while the list render sits in a lower-priority lane. You can also wrap the filter call in performance.mark and performance.measure to compare main-thread time before and after adding the hook. These steps observe behavior; they do not constitute a performance benchmark.
When to reach for each hook
Start with useDeferredValue when an input drives a derived list and you want the text box to stay fluid. Add useTransition when an event such as a sort or filter submission triggers a heavy render and you need an isPending flag to show temporary UI. Profile first, then add concurrency only where the user actually feels lag.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.