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
Class | Description |
---|---|
SyncExternalStore | A simple SyncExternalStore for use with React’s useSyncExternalStore . |