Home
React
Suspense: useTransition()
Daniel Nguyen
Daniel Nguyen
July 29, 2025
1 min

useTransition lets you mark state updates as non-urgent, allowing React to prioritize interactions while preparing less urgent UI updates.

1. The Problem: Expensive Updates

Imagine filtering thousands of items while a user types into a search input.

setFilter(value);

If updating the filter triggers expensive rendering, the input may become sluggish because React has to process a large amount of UI work.

2. The Solution: useTransition

const [isPending, startTransition] = useTransition();
  • startTransition: Marks state updates inside its callback as non-urgent.
  • isPending: Indicates that the transition is still pending.

3. Practical Example: Search Filtering

function SearchPage({ items }) {
const [input, setInput] = useState("");
const [filter, setFilter] = useState("");
const [isPending, startTransition] = useTransition();
function handleChange(event) {
const value = event.target.value;
setInput(value); // Urgent update
startTransition(() => {
setFilter(value); // Non-urgent update
});
}
const filteredItems = items.filter(item =>
item.name.toLowerCase().includes(filter.toLowerCase())
);
return (
<>
<input value={input} onChange={handleChange} />
{isPending && <span>Updating results...</span>}
<ul>
{filteredItems.map(item => (
<li key={item.id}>{item.name}</li>
))}
</ul>
</>
);
}

The input updates urgently, while the filter state update is marked as a transition. React can prioritize typing over rendering the updated results.

For very large datasets, consider memoizing the expensive list or using virtualization as well.

4. What useTransition Does Not Do

  • It does not make CPU-intensive JavaScript execute faster.
  • It does not move rendering to a separate thread.
  • It does not debounce input or reduce network requests.
  • It cannot interrupt a long-running synchronous function in the middle of execution.

Instead, it allows React to schedule rendering work according to priority.

5. When Should You Use It?

Use useTransition for expensive filtering, switching tabs, navigating between views, or rendering data-heavy UI where an update can wait while urgent interactions remain responsive.


Tags

#ReactSuspense

Share

Daniel Nguyen

Daniel Nguyen

Frontend Developer

Frontend developer specializing in React, Next.js, and JavaScript. Writing practical guides on modern web development at Dev98.

Expertise

React
Next.js
JavaScript
TypeScript
Python

Social Media

githublinkedinyoutubewebsite

Related Posts

React Suspense
Suspense: useFormStatus()
August 01, 2025
1 min
Dev98

Dev98

React · Next.js · Web development