# @koenbrouwer/react-usetoggle

> React useToggle hook

Latest version **1.1.2** (published 2020-06-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install @koenbrouwer/react-usetoggle
pnpm add @koenbrouwer/react-usetoggle
yarn add @koenbrouwer/react-usetoggle
bun add @koenbrouwer/react-usetoggle
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2020-06-15 |
| First published | 2020-03-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 2.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Koen Brouwer |
| Maintainers | koenbrouwer |
| Keywords | react, hook, useToggle |

## Links

- npm: https://www.npmjs.com/package/@koenbrouwer/react-usetoggle
- Repository: https://github.com/KoenBrouwer/react-usetoggle
- Homepage: https://github.com/KoenBrouwer/react-usetoggle#readme
- Issues: https://github.com/KoenBrouwer/react-usetoggle
- npm.io page: https://npm.io/package/@koenbrouwer/react-usetoggle

## Dependencies (1)

- [react](https://npm.io/package/react.md) ^16.13.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2020-06-15
- 1.1.0 — 2020-03-17
- 1.0.3 — 2020-03-16
- 1.0.2 — 2020-03-16
- 1.0.1 — 2020-03-15
- 1.0.0 — 2020-03-15

## README

### 🙋‍♂️ Made by [@koenbrouwer](https://twitter.com/KoenBrouwer).

> ⚠️ This hook is now part of my collection of hooks called [react-grapple](https://github.com/KoenBrouwer/react-grapple).
Feel free to open an issue or a pull request in that [repo on GitHub](https://github.com/KoenBrouwer/react-grapple/pulls)!
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](https://github.com/KoenBrouwer/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](https://nodejs.org/en/) package available through the [npm registry](https://nodejs.org/en/).
Installation into your project is done with the [`npm install` command](https://docs.npmjs.com/downloading-and-installing-packages-locally): 

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 then`toggleState()` will toggle the value from `true` to `false`, or `false` to `true`.

# License

[MIT](https://en.wikipedia.org/wiki/MIT_License)

---
_Source: https://npm.io/package/@koenbrouwer/react-usetoggle · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
