apiref
sync-external-store@1.0.0

SyncExternalStore  Class

A simple SyncExternalStore for use with React’s useSyncExternalStore.

Signature

export declare class SyncExternalStore<T> 

Constructors

ConstructorDescription
(constructor)(initialState)Creates a new SyncExternalStore.

Properties

PropertyTypeDescription
getSnapshot() => TThe getSnapshot function to pass as the 2nd argument to useSyncExternalStore.
stateTThe current state of the store. Assigning a new value to this property will cause all subscribers to be notified.
subscribe(onStoreChange: (value: T) => void) => () => voidThe subscribe function to pass as the 1st argument to useSyncExternalStore.