Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 16.7 — Concurrent Rendering: useTransition and useDeferredValue
React · Example 1 of 2

useTransition: the old tab stays while the new one renders

One click, two renders: first urgent (old tab, isPending true), then the transition (new tab). Click Posts then Home quickly yourself: Home wins at once, because React drops the unfinished Posts render. Each post takes 1 ms in this development build; production is faster, but the pattern is the same.

Concurrent rendering lets React prepare a slow update in the background and interrupt it for urgent ones; useTransition marks a state update as non-urgent and gives you isPending, and useDeferredValue lets a slow part of the screen lag behind a fast-changing value so typing stays responsive.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

A FilterPanel changes category state and a big ProductGrid re-renders slowly. Make category changes non-blocking and dim the grid while pending.

02

A Results component receives query as a prop from a parent you can't change. Make the input above it stay responsive.

Explain it without notes

01

What is the difference between an urgent update and a transition?

02

What happens, step by step, when you call startTransition(() => setTab("posts"))?

03

When would you choose useDeferredValue over useTransition?

04

Why must the slow component be memoised for useDeferredValue to help?

useTransition: the old tab stays while the new one renders

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

App rendered: tab = home, isPending = false
--- click Posts
App rendered: tab = home, isPending = true
App rendered: tab = posts, isPending = false