0.2.3 • Published 2 years ago
@andrewizbatista/use-bool v0.2.3
useBool
A simple React hook that encapsulates the logic around a boolean
value with ZERO dependencies.
Table of Contents
Getting Started
Prerequisites
This package has peerDependencies
that are required for you to include in your app's dependencies
:
{
"dependencies": {
"react": "^17.0.2"
}
}
Installing
yarn
yarn add @andrewizbatista/use-bool
npm
npm install @andrewizbatista/use-bool
Usage
Use it as you would use any other React hook.
import { useBool } from '@andrewizbatista/use-bool';
function Usage() {
// Normal usage
const { bool, toTrue, toFalse, toggle } = useBool(false);
// Tip: In ES6 you can rename your object keys!
const {
bool: open,
toTrue: openModal,
toFalse: closeModal,
toggle: toggleModal,
} = useBool(false);
return (
...
)
}
Contributing
Want to help? Feel free to open an Issue or create a Pull Request and let's get started 🚀
License
MIT © André Batista (@andrewizbatista) 🎉