Docs
useToggle
Easily manage a boolean state with useToggle.
Installation
Usage
API Reference
Parameters
Name | Type | Description |
---|---|---|
defaultValue? | boolean | The initial value for the toggle state. |
Returns
The useToggle
hook returns a tuple with the following elements:
Index | Type | Description |
---|---|---|
0 | boolean | The current toggle state value. |
1 | () => void | Function to toggle the state. |
2 | Dispatch<SetStateAction<boolean>> | Function to set the toggle state directly. |