Skip to content

Toleckk/use-boolean-state

Repository files navigation

use-boolean-state

React hook providing functions for boolean state management

NPM JavaScript Style Guide

Install

yarn add use-boolean-state

or if you use npm

npm install --save use-boolean-state

Usage

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>
  )
}

Demo

License

MIT © Toleckk


This hook is created using create-react-hook.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •