The isPending Flag for Loading States
You'll learn how to use the isPending flag from useTransition to display loading feedback during non-urgent state updates without blocking user input.
The Missing Piece
When you mark a state update as non-urgent using useTransition's startTransition, React doesn't block the UI—great! But your users need some indication that their action is being processed. That's where the isPending flag comes in.
The useTransition hook returns an array with two values: [isPending, startTransition]. The isPending boolean is true whenever a transition is in progress, and false otherwise.
const [isPending, startTransition] = useTransition();
function handleSearch(text) {
startTransition(() => {
setSearchQuery(text);
});
}
Showing Feedback Without Blocking
Think of isPending like a progress indicator on a package delivery: it tells you something's happening, but doesn't stop you from doing other things.
You can use this flag to add subtle loading indicators:
<input
value={input}
onChange={(e) => {
setInput(e.target.value);
startTransition(() => setSearchQuery(e.target.value));
}}
style={{ opacity: isPending ? 0.6 : 1 }}
/>
{isPending && <span>Searching...</span>}
The input remains responsive—users can keep typing—while the dimmed appearance or message tells them the search results are updating. This is fundamentally different from a traditional loading state that would disable the input entirely.
When to Use It
Use isPending to indicate background work that shouldn't interrupt the user's flow—filtering lists, updating previews, or recalculating derived data.
Key Takeaway: The isPending flag from useTransition lets you show loading feedback for non-urgent updates while keeping your UI fully interactive and responsive.