Concurrent React and Suspense · senior
<Activity> and <ViewTransition>
<Activity mode="hidden"> (React 19.2) hides a subtree with display: none, keeps its state and DOM, and unmounts its effects; <ViewTransition> (stable in 19.3) animates elements with the browser View Transition API when they change inside a transition.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
<Activity mode={visible ? "visible" : "hidden"}>: hidden children keep state and DOM, effects are cleaned up (re-created on show), and updates still render at low priority.- Compared with
{show && <X />}(state lost) and CSS hiding (effects keep running), Activity keeps state but stops effects. - Uses: tabs that keep form drafts, back/forward caches, pre-rendering a likely next page (only Suspense-based data like
use()is prefetched, not effect fetches). Next.js 16 uses it in navigation. - Caveats:
<video>/<audio>/<iframe>keep playing when hidden (pause in a layout-effect cleanup); think of hidden as "unmounted" for effects. React 19.3 fixeduseSyncExternalStoremissing changes while hidden. <ViewTransition>animates only updates inside a transition:startTransition, a Suspense reveal, oruseDeferredValue. UrgentsetStatedoes not animate.- Animation types: enter, exit, update, and share (a named ViewTransition removed in one place and added in another = shared element). Default is a cross-fade; customise with CSS classes or
onEnter/onExit/onUpdate/onShare+ Web Animations API. addTransitionType("next")insidestartTransitionlets one update animate differently (forward vs back).- DOM only for now (React Native in progress). Respect
prefers-reduced-motion.
The red pen
Common traps: mistake → fix
Mistake: "Hidden Activity keeps polling"
Fix: its effects are unmounted.
Mistake: "Activity is the same as display:none"
Fix: it also unmounts effects and lowers update priority.
Mistake: "ViewTransition animates any setState"
Fix: only transition updates.
Easy to hard
Questions interviewers ask, easy to hard
- Tabs must keep form state when you switch away but stop the hidden tab's polling. How do you build it today?
- What happens to effects in
mode="hidden"? - How would you animate a list-to-detail shared element transition in React 19.3?
- Why does a normal
setStatenot animate with<ViewTransition>?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.