Socket
Socket
Sign inDemoInstall

modal-state

Package Overview
Dependencies
3
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    modal-state

Control your modal more easily with useModal hook


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Modal State

Getting Started

You can use this react hook to control your modal more easily. It provides a better code representation of modal state, which is useful when you are managing multiple modals. Also you can attach callbacks for every action of modal, like opening and closing of modal.

Installation

To install and set up the library, run:

npm install -S modal-state

Or if you prefer using Yarn:

yarn add --dev modal-state

How to use

const Component = () => {
  const modal = useModal();

  return (
    <body>
      <button onClick={modal.open}>Open modal</button>
      <Modal isOpen={modal.isOpen} onClose={modal.close}></Modal>
    </body>
  );
};

Attach callbacks

const modal = useModal({
  onClose: () => {
    //gets executed when modal is closed
  },
  onOpen: () => {
    //gets executed when modal is opened
  },
});

Keywords

FAQs

Last updated on 07 Jan 2023

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