The useBoolean Hook is used to deal with toggling boolean values (true/false), and provides functions to set the value to true/false, and a toggle function to toggle the value.
The Hook returns an object with the following:
- value: The current value of the boolean
- toggle: A function to toggle the current value (sets true if currently false, and false if currently true)
- setTrue: Sets the current value to true
- setFalse: Sets the current value to false
The Boolean Hook works as follows:
- First, we import the useBoolean Hook from react-hookedup:
import React from 'react'import { useBoolean } from 'react-hookedup'
- Then, we define our component and the Boolean Hook, which returns an object with the toggle function and value ...