Course contentsShow
← React
Lesson 2302 of 2,39650. Performance: Optimization TechniquesFree lesson

What useTransition Does: Marking Updates as Non-Urgent

Learn how useTransition splits updates into urgent and non-urgent, allowing React to keep the UI responsive during heavy renders.

What useTransition Does: Marking Updates as Non-Urgent

You'll learn how useTransition allows React to keep your UI responsive by marking certain state updates as "non-urgent," so they don't block critical user interactions.

The Core Problem

Imagine typing in a search box that filters a massive list of 10,000 items. Without optimization, every keystroke triggers a synchronous update that re-renders the entire list, freezing the input field until React finishes. The user's typing feels sluggish and unresponsive because React treats all updates as equally urgent.

How useTransition Works

useTransition lets you mark specific updates as non-urgent transitions. When you wrap a state update in a transition, you're telling React: "This update is important, but if the user is actively interacting with something else, prioritize that instead."

React splits your updates into two categories:

  • Urgent updates: Direct user input like typing, clicking, hovering
  • Non-urgent updates (transitions): Secondary effects like filtering results, updating charts, or changing views

During a transition, React keeps the current UI interactive and responsive. If a new urgent update arrives (like another keystroke), React pauses the transition work, handles the urgent update first, then resumes the background work.

The Mental Model

Think of it like a restaurant kitchen: urgent updates are orders for customers waiting at their tables (handle immediately), while transitions are prep work for tomorrow's menu (important, but can pause if new orders arrive).

This is especially powerful for expensive renders you've identified through profiling—transforms that previously blocked the UI can now happen in the background.

Key Takeaway: useTransition gives React permission to defer and interrupt certain updates, maintaining UI responsiveness during heavy rendering work without losing the update itself.