Tracks value of a boolean
import { useToggle } from 'use-haki';
const App = () => {
const { on, toggle } = useToggle();
return (
<div>
<span>{on && 'Hi there 👋'}</span>
<button onClick={toggle}>toggle me 👀</button>
</div>
);
};
const { on, toggle } = useToggle(initialOn);
- initialValue - initialOn by default is false
- on - toggle state
- toggle - function that toggle
on
state
- toggle
- on