Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/farwayer/react-use-bool

Simple React boolean hooks
https://github.com/farwayer/react-use-bool

Last synced: 4 days ago
JSON representation

Simple React boolean hooks

Awesome Lists containing this project

README

        

## react-use-bool

_Simple React boolean hooks_

[![NPM version](https://img.shields.io/npm/v/react-use-bool.svg)](https://www.npmjs.com/package/react-use-bool)

## How to use

```bash
yarn add react-use-bool
```

```js
import {useBool, useToggle} from 'react-use-bool'

function Lamp() {
const [on, turnOn, turnOff] = useBool()

return (


{on ? "ON" : "OFF"}

TURN ON
TURN OFF

)
}

function ToggleLamp() {
const [on, toggle, setValue] = useToggle(true)

return (


{on ? "ON" : "OFF"}

TOGGLE
setValue(false)}>OFF

)
}
```