apiref
sync-external-store@1.0.0

sync-external-store  EntryPoint

A simple implementation of a SyncExternalStore for use with React 18’s useSyncExternalStore.

Example

const store = new SyncExternalStore(0);

function App() {
  const count = useSyncExternalStore(store.subscribe, store.getSnapshot);
  return (
    <button type="button" onClick={() => store.state++}>
      {count}
    </button>
  );
}

Classes

ClassDescription
SyncExternalStoreA simple SyncExternalStore for use with React’s useSyncExternalStore.