1.1.2 • Published 4 years ago

@koenbrouwer/react-usetoggle v1.1.2

Weekly downloads
6
License
ISC
Repository
github
Last release
4 years ago

🙋‍♂️ Made by @koenbrouwer.

⚠️ This hook is now part of my collection of hooks called react-grapple. Feel free to open an issue or a pull request in that repo on GitHub! The current repository is still usable, but no longer maintained. If you want to use an up to date and supported version of the useToggle-hook, use react-grapple instead.


react-usetoggle

Very simple hook for React to have a named boolean in a useState hook.

Quick Start

This is a Node.js package available through the npm registry. Installation into your project is done with the npm install command:

To install:

npm install --save @koenbrouwer/react-usetoggle

Usage:

const [state, toggleState] = useToggle(); // defaults to false

You can also give it another default initial state:

const [state, toggleState] = useToggle(true); // defaults to true

If you don't give it a default value, it will default to false, or the boolean you feed it. And thentoggleState() will toggle the value from true to false, or false to true.

License

MIT

1.1.2

4 years ago

1.1.1

4 years ago

1.1.1-0

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago