@ybroeker/react-toggle-hook
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

react-toggle-hook

Usage

import React from 'react'
import {useToggle} from "@ybroeker/react-toggle-hook";

const App = () => {
  const [state, enable, disable, toggle] = useToggle()

  return (
    <div className="App">

      <span>Current state: {state ? 'true' : 'false'}</span>

      <button onClick={enable}>Enable</button>
      <button onClick={disable}>Disable</button>
      <button onClick={toggle}>Toggle</button>

      <input type="checkbox" checked={state} onChange={toggle}/>
    </div>
  )
}

Readme

Keywords

Package Sidebar

Install

npm i @ybroeker/react-toggle-hook

Weekly Downloads

2

Version

0.2.0

License

MIT

Unpacked Size

3.47 kB

Total Files

5

Last publish

Collaborators

  • ybroeker