@darwish/hooks-core
Version:
25 lines (24 loc) • 1.06 kB
TypeScript
export type UseBooleanOutput = {
value: boolean;
set: (settingValue: boolean) => void;
setTrue: () => void;
setFalse: () => void;
toggle: () => void;
};
/**
* @author darwish
* @param defaultValue a boolean value
* @description a hook to toggle boolean value
* @returns `UseBooleanOutput` An object containing the boolean state value and utility functions to manipulate the state.
* @property {Function} `UseBooleanOutput.set` sets the value
* @property {Function} `UseBooleanOutput.value` the current boolean value
* @property {Function} `UseBooleanOutput.setTrue` sets the value to `true`
* @property {Function} `UseBooleanOutput.setFalse` sets the value to `false`
* @property {Function} `UseBooleanOutput.toggle` toggles the value
* @see [Documentation](https://darwish.vercel.app/hooks/use-boolean)
* @example
* const {value, setTrue, setFalse, toggle} = useBoolean(true);
* <button onClick={toggle}>Toggle</button>
*/
declare const useBoolean: (defaultValue?: boolean) => UseBooleanOutput;
export default useBoolean;