README
useToggle
Simple hook that return a boolean value and a function to toggle it.
Installation
yarn add @ofqwx/useToggle
Example
import useToggle from "@ofqwx/useToggle";
// or from @ofqwx/react-hooks:
// import {useToggle} from "@ofqwx/react-hooks
function YourComponent() {
const [toggled, toggle] = useToggle();
return <AnotherComponent display={toggled} onToggle={toggle} />;
}
you can also call it with optional initialiser value (default is false):
const [toggled, toggle] = useToggle(true);
Tests
yarn install
yarn test