New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-async-dialog

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-async-dialog

Yes, you can do `await dialog.alert(<YourComponent />)` out of the box!

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

react-async-dialog

Yes, you can do await dialog.alert(<YourComponent />) out of the box!

npm install react-async-dialog
yarn add react-async-dialog

storybook.png

Why?

React provides a first-class way to use Portals, which makes modals easy to create.

But sometimes, you want a modal window that interferes your event handlers.

if (
  await dialog.confirm(
    <>
      Are you <strong>REALLY</strong> sure?
    </>
  )
) {
  console.log("Ok, you are so sure!")
}

This library gives you this behavior out of the box!

How to use

import { DialogProvider, useDialog } from "react-async-dialog"

function YourApp(save) {
  const dialog = useDialog()

  const onSave = async e => {
    e.preventDefault()

    const ok = await dialog.confirm(<strong>Are you sure???</strong>, {
      ok: "YES!!!"
    })
    if (!ok) {
      return
    }

    save()
  }

  return <button onClick={onSave}>SAVE ME</button>
}

ReactDOM.render(
  <DialogProvider>
    <YourApp save={api.save} />
  </DialogProvider>,
  root
)

Polyfills

react-async-dialog requires Promise.

FAQs

Package last updated on 13 Nov 2019

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