@kodai3/use-boolean
v0.0.3
Published
React state hook that tracks value of a boolean.
Downloads
8
Readme
useBoolean
React state hook that tracks value of a boolean.
Usage
import { useBoolean } from "@kodai3/use-boolean";
const Demo = () => {
const [on, toggle] = useBoolean(true);
return (
<div>
<div>{on ? "ON" : "OFF"}</div>
<button onClick={toggle}>Toggle</button>
<button onClick={() => toggle(true)}>set ON</button>
<button onClick={() => toggle(false)}>set OFF</button>
</div>
);
};