1.0.2 • Published 5 years ago
use-toggle
Like useState
, but for toggling something on/off.
Install
yarn add @flaque/use-toggle
Usage
import useToggle from '@flaque/use-toggle'
function MySwitch() {
const [isOn, toggleIsOn] = useToggle(true)
return (<>
<p>{`I am ${isOn ? "on" : "off"}`}</p>
<button onClick={toggleIsOn}>
</>)
}