@supunlakmal/hooks
Version:
A collection of reusable React hooks
16 lines (15 loc) • 685 B
TypeScript
/**
* @name useBoolean
* @description - Hook that manages a boolean state, providing explicit setTrue, setFalse, and toggle functions.
*
* @param {boolean} [initialValue=false] The initial value of the boolean state.
* @returns {[boolean, { setTrue: () => void; setFalse: () => void; toggle: () => void; }]} A tuple containing the current boolean value and an object with functions to manipulate it.
*
* @example
* const [isVisible, { setTrue: openModal, setFalse: closeModal, toggle: toggleModal }] = useBoolean(false);
*/
export declare const useBoolean: (initialValue?: boolean) => [boolean, {
setTrue: () => void;
setFalse: () => void;
toggle: () => void;
}];