Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardReactuseSyncExternalStoreSingle-choice MCQ3 views

Why can a useState-based subscription to an external store (the pre-18 pattern of setState in an effect) silently MISS a store mutation that happens between the initial render and the effect running, in a way useSyncExternalStore does not?

// legacy pattern const [snap, setSnap] = useState(store.getSnapshot()); useEffect(() => { const unsub = store.subscribe(() => setSnap(store.getSnapshot())); return unsub; }, []);