qol-hooks
Version:
A collection of React hooks to improve the quality of life of developers.
15 lines (14 loc) • 518 B
TypeScript
/**
* @description A hook to toggle a boolean value
* @param {boolean} initialValue The initial value of the boolean
* @returns {[boolean, (value: boolean) => void]} A tuple containing the boolean value and a function to toggle the value
*
* @example```tsx
* const [value, toggleValue] = useToggle();
*
* <button onClick={toggleValue}>Toggle</button>
* {value && <div>Visible</div>}
* ```
*/
declare function useToggle(initialValue?: boolean): [boolean, (value: boolean) => void];
export default useToggle;