@supunlakmal/hooks
Version:
A collection of reusable React hooks
14 lines (13 loc) • 555 B
TypeScript
/**
* A hook that provides a boolean state that persists in local storage,
* along with a function to toggle it.
*
* @param key The key to use in local storage.
* @param initialValue The initial value to use if no value is found in local storage.
* @returns A tuple containing the current state, a toggle function, and the raw setter function from useLocalStorage.
*/
export declare function usePersistentToggle(key: string, initialValue: boolean): [
boolean,
() => void,
(value: boolean | ((prevState: boolean) => boolean)) => void
];