useToggle
Simple boolean state toggler
Checkout the Storybook demo.
Installation
yarn add @charlietango/use-toggle
API
const toggledInitially = false
const [isToggled, toggle] = useToggle(toggledInitially)
Example
import React from 'react'
import useToggle from '@charlietango/use-toggle'
const Component = () => {
const [isToggled, toggle] = useToggle(true)
return <button onClick={toggle}>{isToggled}</button>
}
export default Component