Capítulo 65 de 116
useTransition() marks a state update as a low-priority "transition," letting React keep the current UI responsive (and interruptible by more urgent updates like typing) while the transition's render work happens in the background, plus it defines what an "Action" is throughout the rest of the Hooks in this reference section.
const [isPending, startTransition] = useTransition(). Wrap a state update in startTransition(() => setState(...)) to mark it non-urgent; isPending is true while that transition's render work is still in progress.startTransition so it doesn't block the input from feeling instant.startTransition (including async functions passed to a form's action prop) are called Actions throughout the rest of this reference — useActionState and useOptimistic are both built around this same underlying mechanism, supporting async functions directly (a transition can await work and keep isPending true until it resolves).useDeferredValue: useTransition marks the state update itself as low priority (you control the setState call); useDeferredValue (Ch 52) instead lets a received value lag behind, useful when you don't control where the state update originates (e.g. a value coming from a parent prop).const [isPending, startTransition] = useTransition();
function selectTab(nextTab) {
startTransition(() => {
setTab(nextTab); // expensive re-render of tab content, marked low-priority
});
}
isPending available to show a loading indicator.startTransition when you own the setState call and want its render work deprioritized; use useDeferredValue instead when you only receive a value, not the update that produced it.useActionState/useOptimistic/form action for exactly this transition-wrapped-function concept — understanding this Hook first makes those others click faster.