useToggle
useToggle toggles a boolean value.
Install
To start using useToggle, you can install the @react-awesome/use-toggle
library or you can import it directly from @react-awesome/components
if you have installed it before. In your project directory, run
the following command to install the dependencies:
npm i @react-awesome/use-toggle
Usage
import { useToggle } from '@react-awesome/use-toggle'
const Example = () => {
const [isOn, toggle] = useToggle(state)
return <input checked={isOn} type="checkbox" onClick={toggle} />
}
Parameters
The useToggle
takes the following parameters:
value
- Type:
boolean
API
The useToggle
returns the following props:
isOn
- Type:
boolean
toggle
- Type:
(value?: boolean) => void