Creates a state provider for React components with support for persistent state storage.

  • Type Parameters

    • S extends unknown

      The type of the state object.

    Parameters

    • storageKey: string

      The key used to store the state in the storage manager.

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

    • An array containing the WrappedStateProvider and useStateProvider components.