useSyncExternalStore
useSyncExternalStore
is a hook recommended for reading and subscribing from external data sources in a way that’s compatible with concurrent rendering features like selective hydration and time slicing.
const state = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot?);