useBoolean
Custom hook that handles boolean state with useful utility functions.
Installation
npx sse-hooks add use-boolean
yarn dlx sse-hooks add use-boolean
pnpm dlx sse-hooks add use-boolean
deno run -A npm:sse-hooks add use-boolean
bunx sse-hooks add use-boolean
Usage
example.ts
import { useBoolean } from "./{hooks file}";
const { value, setTrue, setFalse, toggle } = useBoolean(true);
API
Parameters
| Prop | Default | Type |
|---|---|---|
defaultValue |
|
The initial value for the boolean state (default is |
Returns
| Return Value | Default | Type |
|---|---|---|
setFalse | - |
Function to set the boolean state to |
setTrue | - |
Function to set the boolean state to |
setValue | - |
Function to set the boolean state directly. |
toggle | - |
Function to toggle the boolean state. |
value | - |
The current boolean state value. |
Types Aliases
No specific type aliases defined for this component.