React hook providing functions for boolean state management
yarn add use-boolean-state
or if you use npm
npm install --save use-boolean-state
import React from 'react'
import useBooleanState from 'use-boolean-state'
const Example = () => {
const [showing, show, close, toggle] = useBooleanState(false)
return (
<div>
<button onClick={show}>Show</button>
<button onClick={close}>Close</button>
<button onClick={toggle}>Toggle</button>
{showing && <div>Meow</div>}
</div>
)
}
MIT © Toleckk
This hook is created using create-react-hook.