Skip to the page

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.

The 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 fixed useSyncExternalStore missing changes while hidden.
  • <ViewTransition> animates only updates inside a transition: startTransition, a Suspense reveal, or useDeferredValue. Urgent setState does 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") inside startTransition lets 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

  1. Tabs must keep form state when you switch away but stop the hidden tab's polling. How do you build it today?
  2. What happens to effects in mode="hidden"?
  3. How would you animate a list-to-detail shared element transition in React 19.3?
  4. Why does a normal setState not animate with <ViewTransition>?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview