useBoolean
Manages a boolean state with helper functions to set, reset, and toggle the value.
Loading preview...
The useBoolean hook manages a boolean state and provides memoized helper callbacks (setTrue, setFalse, toggle, and setValue) for common state transitions.
Installation
Usage
Examples
Controlling a Dialog
Use setTrue and setFalse directly as event handlers without creating inline arrow functions.
Toggling State
Use toggle to flip the current boolean value, or setValue when you need to pass an explicit boolean.
API Reference
UseBooleanReturn
State and helper functions returned by the hook.
Property
Specification
valueunion
Current boolean state
Full Signature
setValueDispatch<SetStateAction<union>>
Standard React state setter
Full Signature
setTruefunction
Sets the state to
trueFull Signature
setFalsefunction
Sets the state to
falseFull Signature
togglefunction
Flips the current boolean state
Full Signature