useToggle
Returns a stateful value with two functions to update it.
useToggle
Installation
Usage
API
useToggle
Returns a stateful value and two functions to update it.
Parameters
| Name | Type | Description |
|---|---|---|
| defaultValue | boolean | The initial value of the state. Default is false. |
Returns
| Name | Type | Description |
|---|---|---|
| isOn | boolean | The current value of the state. |
| toggle | () => void | A function to toggle the state. |
| setToggle | Dispatch | A function to set the state to a new value. |