Socket
Book a DemoInstallSign in
Socket

@foundernest/react-modal-promise

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@foundernest/react-modal-promise

Modal promise wrapper for React components

0.2.3
latest
Source
npmnpm
Version published
Maintainers
2
Created
Source

Install

npm install react-modal-promise

or

yarn add react-modal-promise

How to use:

  • Place ModalContainer in root of your App:
import ModalContainer from 'react-modal-promise'

class MyApp extends React.Component {
  render () {
    return (
      <ModalContainer />
    )
  }
}
  • Create you own modal component:

You need pass (open: bool) flag to you Modal component

Close modal and resolve Promise by call close() function from props

import { createModal } from 'react-modal-promise'
import { Modal } from 'react-bootstrap'

const MyModal = ({ open: bool, close: function, /*...any props was passed to modal*/ }) => (
  <Modal open={open} onHide={() => close()}>
    My Super Promised modal
    <button onClick={() => close(/*pass any value*/)}>Confirm modal</button>
  </Modal>
)

And wrap it:

const myPromiseModal = createModal(MyModal)

  • Use modal as Promise everywhere:
myPromiseModal({ /*pass any props here*/ }).then(value => {
  // get value that you pass to 'close' function
})

Features

You can use react-modal-promise with any theming (Bootstrap or material-ui, styled-components, or other), all instances works perfectly!

Keywords

foundernest

FAQs

Package last updated on 12 Apr 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.