• A React hook that registers a handle for synchronization using a synchronized state object.

    This hook will create a synchronized state object using the useSyncState hook with the given initial state and update event. It will then register a handle with the given ID and the synchronized state object. The handle will be unregistered when the component using the hook unmounts.

    By default, only the hosting component will be updated when the state changes. Other components can consume this handle using useHandle (if state updates do not need to trigger rerendering in the consumer, or if the consuming component will handle its own subscription), or useSyncHandle to gain access to the handle in the consumer and get rerendering triggered.

    Type Parameters

    • T extends object

      extends object

    Parameters

    • ID: Path

      The ID to register the handle with.

    • initialState: T

      The initial state of the handle.

    • Optional updateEvent: string = 'set'

      The event that triggers an update to the handle.

    Returns ReactiumSyncState<T>

    The current state of the handle.

    See