Nightly Pocket Measurement

    @charlietango/use-toggle
    TypeScript icon, indicating that this package has built-in type declarations

    1.4.0 • Public • Published

    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

    Keywords

    Install

    npm i @charlietango/use-toggle

    DownloadsWeekly Downloads

    122

    Version

    1.4.0

    License

    MIT

    Unpacked Size

    4.15 kB

    Total Files

    6

    Last publish

    Collaborators

    • thebuilder
    • frederik_bosch