UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

20 lines 1.09 kB
import * as React from 'react'; type Initializer = () => string | null; type UseStorageStateHookResult = [string | null, React.Dispatch<React.SetStateAction<string | null>>]; /** * Sync state to local storage so that it persists through a page refresh. Usage is * similar to useState except we pass in a storage key so that we can default * to that value on page load instead of the specified initial value. * * Since the storage API isn't available in server-rendering environments, we * return null during SSR and hydration. * * @param key - localStorage key. If null, persistence is disabled and * the hook behaves like regular useState. * @param initializer - Initial value or function returning initial value * @returns A tuple of [value, setValue] where value is the current value * from localStorage (or the initial value) and setValue updates it */ declare function useLocalStorageStateBrowser(key: string | null, initializer?: string | null | Initializer): UseStorageStateHookResult; declare const _default: typeof useLocalStorageStateBrowser; export default _default;