useSyncExternalStore
Learn how useSyncExternalStore safely subscribes React components to external, mutable data sources under concurrent rendering.
useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot?) is the official hook for reading data from a store that lives outside React — like a third-party state library, a browser API such as window.innerWidth, or a custom event-emitter-based store — while remaining correct under React 18's concurrent rendering features.
It's like a newsroom pulling live wire feed updates: useSyncExternalStore is the strict editorial rule that every article printed in a single edition (one render) uses the exact same version of a breaking story, even if the wire service pushes an update while the presses (React's concurrent renderer) are mid-run.