Socket
Book a DemoInstallSign in
Socket

@foundernest/react-promise-components

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@foundernest/react-promise-components

Promise wrapper for React components

latest
Source
npmnpm
Version
0.3.4
Version published
Maintainers
3
Created
Source

Motivation

Modals and some components work like a promise, they "pause" your main app waiting for a result. Using a local/redux state for managing this kind of components lacks ease when chaining results of different "promise" components.

Originally forked from https://github.com/cudr/react-modal-promise

Install


npm install react-promise-components

or


yarn add react-promise-components

How to use:

  • Place PromiseComponentsContainer in root of your App:

import PromiseComponentsContainer from 'react-promise-components'

function MyApp {
	return (
		{/* ... other components */}
		<PromiseComponentsContainer />
	)
}

  • Create you own promise component:

Close your and resolve promise component by calling handleClose() function from props

You can transform your props with the mapProps argument


import { createPromiseComponent } from 'react-promise-components'

import { Modal } from 'react-bootstrap'



// Bootstrap modal needs open and onHide

const bootstrapModal = createPromiseComponent(Modal,
	({ transitionState, handleClose, ...props }) => {
		open: transitionState !== 'exiting',
		onHide: handleClose,
		...props
	})

  • Use as Promise everywhere:

bootstrapModal({ /*pass any props here*/ }).then(value => {
// get value that you pass to 'close' function
})

Keywords

foundernest

FAQs

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

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.