useBoolean
useBoolean
is a custom hook used to manage a boolean value with on
, off
and toggle
functions.
Import​
import { useBoolean } from '@react-native-material/core'
Return value​
The useBoolean
hook returns a stateful boolean value and an object with the following function to update it:
Name | Type | Description |
---|---|---|
on | () => void | A function to set the boolean value to true . |
off | () => void | A function to set the boolean value to false . |
toggle | () => void | A function to negate the boolean state. |
Usage​
Usage of toggle method​
Usage of on and off methods​
Parameters​
The hook useBoolean
accepts the initial boolean value, by default is false
.