New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

popup-provider

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

popup-provider

Await popups in React

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Popup Provider

Await popup results in React

This library provides a comfortable way to create popups and await any data from that popup close action.

Usage

See an example in CodeSandbox

Edit PopupProvider

// ...PopupProvider higher up in the hierarchy
// ... `const context = useContext(PopupContext)` in the component

const isSure = await openPopup<number>(
  context,
  (close) => {
    return (
      <div>
        <p>Are you sure?</p>
        <button onClick={() => close(true)}>Yes</button>
        <button onClick={() => close(false)}>No</button>
      </div>
    );
  },
  'are_you_sure' // any unique string
);

And provide a place to render your popups

return (
  <div>
    {context.layers.map(({ component, resolver, id }) => (
      <div key={id}>
        <section>{component}</section>
        <button onClick={resolver}>Close this</button>
      </div>
    ))}
  <div>
)

Where you can have a button (or background) close the popup. When closed with this method the value is null.

Keywords

FAQs

Package last updated on 02 Mar 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc