
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
react-disposable-modal
Advanced tools
React-disposable-modal is a reactive API for building modal components in React.
React-disposable-modal is a reactive API for building modal components in React.
You want to build a modal in React, but don't want that modal to be
inserted in the DOM immediately where the Modal is rendered, instead you
want it to be appended to document.body.
Modals have are inherently an asyncronous ui component. A modal is displayed, at some point in the future an action is taken from within the modal, and then it is closed. React-disposable-modal provides a reactive API for handling that asyncronous behavior.
yarn add react-disposable-modal
There are two ways to use react-dispoable-modal: an imperative and declarative API:
createCancelableModal(ModalComponent, props) - Takes two parameters, a
custom modal component and optional parameters to pass to the modal.
ModalComponent will be rendered with three extra props:
onNext - Use to pass data to the subscription that invoked the modal. Can be called multiple times.
onError - Use to pass an error to the subscription that invoked the modal.
onCompleted - Use to close the modal.
import { createCancelableModal } from "react-disposable-modal";
import React from "react";
class Modal extends React.Component {
render() {
return (
<div>
<div className="screen" />
<div className="modal">
<h1>My modal for {this.props.name}</h1>
<button onClick={this.props.onCompleted}>Cancel</button>
<button
onClick={() => (
this.props.onNext("I did it!"), this.props.onCompleted()
)}
>
Save
</button>
</div>
</div>
);
}
}
class App extends React.Component {
render() {
return (
<div>
<button onClick={this.showModal}>Show Modal</button>
</div>
);
}
showModal() {
const subscription = createCancelableModal(Modal, {
name: "you",
}).subscribe(data => {
data === "I did it!";
});
subscription.dispose(); // force the modal closed
}
}
Anything put inside the Modal component will be appended to document.body.
import { Modal } from "react-disposable-modal";
import React from "react";
class App extends React.Component {
state = { showModal: false };
render() {
return (
<div>
<button onClick={() => this.setState({ showModal: true })}>
Show Modal
</button>
{this.showModal && (
<Modal>
<div>
<div className="screen" />
<div className="modal">
<h1>My modal for you</h1>
<button onClick={() => this.setState({ showModal: false })}>
Cancel
</button>
<button onClick={() => this.setState({ showModal: false })}>
Save
</button>
</div>
</div>
</Modal>
)}
</div>
);
}
}
React-disposable-modal uses underneath the hood both react-disposable-decorator and disposable-component;
FAQs
React-disposable-modal is a reactive API for building modal components in React.
We found that react-disposable-modal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 13 open source maintainers collaborating on the project.
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.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.