useToggle
About
Toggle (between booleans or custom data)hook for React.
Examples
Basic usage
With a Start value
Custom toggle values
Arguments
Arguments | Type | Description | Default value |
---|---|---|---|
initialValue | boolean | Initial value of the state | false |
toggleFunction | function | Function which determines how to toggle a value | v => !v |
Returned array items
Returned Array items | Type | Description |
---|---|---|
value | Any | Current value |
toggleValue | function | Toggle function which changes the value to the other value in the list of 2 acceptable values. (Mostly true or false) |