@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
26 lines (24 loc) • 1.03 kB
JavaScript
'use client';
import { usePreference } from "../usePreference/usePreference.mjs";
import { useCoordinated } from "./useCoordinated.mjs";
/**
* `usePreference` + {@link useCoordinated} in one call.
*
* Cross-tab sync happens through the underlying `localStorage` /
* `storage` event flow that `usePreference` already provides; the
* coordinator handles within-tab peers so demos that share the same
* preference key commit their visible flip together rather than
* cascading layout shifts.
*
* @param type - Preference type, identical to `usePreference`.
* @param name - Variant/transform name(s), identical to
* `usePreference`.
* @param initializer - Initial value or initializer, identical to
* `usePreference`.
* @param options - Coordination options. Pass `channelKey: null` to
* skip the coordinator entirely.
*/
export function useCoordinatedPreference(type, name, initializer, options) {
const underlying = usePreference(type, name, initializer ?? null);
return useCoordinated(underlying, options);
}