UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

22 lines (20 loc) 907 B
'use client'; import useLocalStorageState from "../useLocalStorageState/index.mjs"; import { useCoordinated } from "./useCoordinated.mjs"; /** * `useLocalStorageState` + coordination in one call. Cross-tab sync * happens via the underlying storage events; the coordinator handles * within-tab peers (sibling demos on the same page) so their visible * value flips land in a single layout pass. * * @param storageKey - localStorage key, or `null` to disable storage * (falls back to regular `useState` semantics). * @param initializer - Initial value, identical to * `useLocalStorageState`. * @param options - Coordination options. Pass `channelKey: null` to * skip the coordinator entirely. */ export function useCoordinatedLocalStorage(storageKey, initializer, options) { const underlying = useLocalStorageState(storageKey, initializer); return useCoordinated(underlying, options); }