Skip to content

QuizNot attempted

Urgent vs transition updates

Is the first setCount call (outside startTransition) treated as urgent or non-urgent, and does wrapping the second call in startTransition change what final value is eventually rendered?
function App() {
const [count, setCount] = useState(0);
const [isPending, startTransition] = useTransition();
const handleClick = () => {
setCount(c => c + 1);
startTransition(() => {
setCount(c => c + 1);
});
};
return <button onClick={handleClick}>{count}</button>;
}
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • First call is urgent (synchronous priority), second is non-urgent; final displayed value is still count + 2 after transition settles
  • The first setCount is a normal (urgent) update
  • the one inside startTransition is a lower-priority, interruptible transition.
  • Both still apply, so the final value is count + 2 once the transition settles.
  • Not 'identical': priority is per update, not per event handler.
  • Not 'first ignored': transitions never drop other updates.
  • Not 'transition blocks the first': the urgent update renders first, possibly before the transition.