Socket
Socket
Sign inDemoInstall

@biggerpixel/use-bool-state

Package Overview
Dependencies
3
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @biggerpixel/use-bool-state

Custom React Hook for boolean state


Version published
Weekly downloads
9
increased by80%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

useBoolState

Usage


npm i @biggerpixel/use-bool-state
import useBoolState from '@biggerpixel/useboolstate';

const Component = () => {
  const [isOpen, toggleIsOpen, setIsOpen] = useBoolState(false); // setIsOpen *optional if you want to set a specific value

  return (
    <div>
      {/* Use Boolean State */}
      {isOpen && <h1>Hello World!</h1>}

      {/* Toggle Boolean State with ease */}
      <button onClick={toggleIsOpen}>Toggle Title</button>

      {/* Set Boolean State with specific value */}
      <button onClick={() => setIsOpen(true)}>Toggle Title</button>
      <button onClick={() => setIsOpen(false)}>Toggle Title</button>
    </div>
  );
};

FAQs

Last updated on 11 Oct 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc