Hooks
useBoolean
Manages a boolean state with stable toggle, setTrue, and setFalse helpers.
Usage
const { value: isOpen, setTrue: open, setFalse: close, toggle } = useBoolean(false)Installation
npx visor add use-booleanParameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
initialValue | boolean | No | false | Initial boolean state value. |
Returns
| Name | Type | Description |
|---|---|---|
value | boolean | Current boolean state. |
setTrue | () => void | Sets state to true. |
setFalse | () => void | Sets state to false. |
toggle | () => void | Toggles state between true and false. |
setValue | (value: boolean) => void | Sets state to an explicit boolean value. |
useAutosave
Autosave for one value — debounces the write, runs one write at a time so the newest value wins, flushes a pending change when the page is left or the component unmounts, and reports saved · saving · unsaved · refused.
useClickOutside
Fires a callback when a click or touch event occurs outside the referenced element.