Function createLsStateProvider

Creates a state provider that persists state in local storage using a given storage key.

  • Type Parameters

    • S extends unknown

      The type of the state.

    Parameters

    • storageKey: string

      The key used to store the state value in local storage.

    Returns readonly [((options: {
        children: ReactNode;
        initialState: S | (() => S);
        onChange?: ((state: S) => void);
    }) => Element), (() => readonly [S, ((state: S | ((prevState: S) => S)) => void)])]

    A tuple containing the wrapped state provider component and the state hook.