import { Dispatch, SetStateAction } from 'react'; /** * Options for {@link useSyncedState}. * * @group Helpers * @beta */ export type UseSyncedStateOptions = { /** * A callback function that is triggered when the state is updated via the local setter, * but not through synchronization with `syncValue`. */ onLocalStateChange?: (state: T) => void; /** * A custom comparison function to determine if the external `syncValue` is different * from the current state. The default function performs a deep equality check using `isEqual`. */ syncCompareFn?: (currentState: T, syncValue: T) => boolean; }; /** * A custom React hook that behaves like the regular `useState`, but also synchronizes the state * with an external `syncValue`. * * @param syncValue - The external value to synchronize with. When this value changes (as * determined by `syncCompareFn`), the local state is updated to match it. * @param options - Optional configuration object. See {@link UseSyncedStateOptions} for the * `onLocalStateChange` and `syncCompareFn` fields. * @returns A tuple of `[localState, setState]` — the current local state and a setter that * both updates state and fires `onLocalStateChange`. * @example * ```tsx * const [localState, setLocalState] = useSyncedState(externalValue, { * onLocalStateChange: (s) => console.log('local update', s), * }); * ``` * @group Helpers * @beta */ export declare function useSyncedState(syncValue: T, { onLocalStateChange, syncCompareFn }?: UseSyncedStateOptions): [T, Dispatch>];