MCPcopy
hub / github.com/facebook/react / useSyncExternalStore

Function useSyncExternalStore

packages/react-server/src/ReactFizzHooks.js:553–565  ·  view source on GitHub ↗
(
  subscribe: (() => void) => () => void,
  getSnapshot: () => T,
  getServerSnapshot?: () => T,
)

Source from the content-addressed store, hash-verified

551}
552
553function useSyncExternalStore<T>(
554 subscribe: (() => void) => () => void,
555 getSnapshot: () => T,
556 getServerSnapshot?: () => T,
557): T {
558 if (getServerSnapshot === undefined) {
559 throw new Error(
560 'Missing getServerSnapshot, which is required for ' +
561 'server-rendered content. Will revert to client rendering.',
562 );
563 }
564 return getServerSnapshot();
565}
566
567function useDeferredValue<T>(value: T, initialValue?: T): T {
568 resolveCurrentlyRenderingComponent();

Callers 13

useSubscriptionFunction · 0.50
AppFunction · 0.50
AFunction · 0.50
BFunction · 0.50
Child1Function · 0.50
Child2Function · 0.50
AppFunction · 0.50
AppFunction · 0.50
AppFunction · 0.50
AFunction · 0.50

Calls 2

getSnapshotFunction · 0.85
getServerSnapshotFunction · 0.50

Tested by 10

AppFunction · 0.40
AFunction · 0.40
BFunction · 0.40
Child1Function · 0.40
Child2Function · 0.40
AppFunction · 0.40
AppFunction · 0.40
AppFunction · 0.40
AFunction · 0.40
BFunction · 0.40