React 19.2’s lets you hide UI while preserving its state and DOM—but it also changes the lifecycle assumptions your code can safely make.
Rendering doesn’t guarantee an Effect. Hidden Activity subtrees can render without their Effects mounting.
Never create side effects during render. Subscriptions and other resources should be created and cleaned up within the same Effect, or use useSyncExternalStore for external stores.
StrictMode is your early warning system. Its extra render and Effect cycles can expose impure rendering and asymmetric cleanup before they become production bugs.
Think carefully about resource ownership. If a WebSocket, timer, or listener should survive hidden UI, manage it above the Activity boundary.
The DOM stays mounted. Effects can be cleaned up while DOM nodes remain, so media and imperative widgets may need explicit cleanup.
State preservation isn't always desirable. Activity works well for tabs and editors, but forms may unexpectedly retain old values and validation state.
Hidden doesn't mean frozen. Activity subtrees can still render in the background and consume memory and resources.
Activity can enable pre-rendering, but not every loading strategy preloads data. Effects won't run while hidden; Suspense-compatible loading can start during render.
The key takeaway: Before using , don't just ask whether it preserves state—ask what code in the subtree relies on the old render → Effect → cleanup lifecycle sequence.
Podden och tillhörande omslagsbild på den här sidan tillhör
HackerNoon. Innehållet i podden är skapat av HackerNoon och inte av,
eller tillsammans med, Poddtoppen.