Course contentsShow
← React
Lesson 1447 of 2,39636. Concurrent ReactFree lesson

useDeferredValue vs useTransition

Choosing useDeferredValue when you don't control the state update, useTransition when you do.

useDeferredValue vs useTransition

What you'll learn: How to choose between useDeferredValue and useTransition based on who controls the state update.

The Key Difference

Both hooks help you handle non-urgent updates, but they differ in where you apply them:

  • useTransition: Use when you control the state setter (you have access to setState, dispatch, etc.)
  • useDeferredValue: Use when you don't control the state update (the value comes from props or external sources)

Control Means Access to the Setter

If you're calling setSearchQuery() directly in your component, you control that update. Wrap the call in startTransition(). But if searchQuery arrives via props from a parent component, you can't wrap someone else's setState call. That's when you defer the value instead.

Practical Decision Tree

Ask yourself: "Can I wrap the state update in startTransition()?"

  • Yes → Use useTransition for cleaner code
  • No → Use useDeferredValue on the incoming value

Example Scenarios

Use useTransition when you own the state:

const [isPending, startTransition] = useTransition();
// You control this update
startTransition(() => setQuery(input));

Use useDeferredValue when receiving props:

// Parent passes 'query', you can't control its update
const deferredQuery = useDeferredValue(query);

Think of it like remote controls: useTransition is pressing the button yourself, while useDeferredValue is adding a delay filter to signals coming from someone else's remote.

Key Takeaway: Choose useTransition when you control the state setter, useDeferredValue when the value comes from outside your control (props, context). They solve the same problem from different angles.