
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@scrumble-nl/react-quick-modal
Advanced tools
A quick and easy wrapper around react-bootstrap modal, you can add or remove a modal from anywhere in your application with a few simple steps.
A quick and easy wrapper around react-bootstrap modal, you can add or remove a modal from anywhere in your application with a few simple steps.
npm install @scrumble-nl/react-quick-modal
or
yarn add @scrumble-nl/react-quick-modal
Add the provider as top level as possible:
import React from 'react';
import App from './src/app';
import {ModalProvider} from '@scrumble-nl/react-quick-modal'; // Don't forget to import this
export default class ModalApp extends React.Component<{}, {}> {
render = (): JSX.Element => {
return (
<ModalProvider>
<App/>
</ModalProvider>
)
}
}
First we need to create a modal with the following steps
Modal
Modal
as the top level element and add the required prop title
4. (optional) do more customization with the other props as shown below the snippetimport React from 'react';
import {Modal} from '@scrumble-nl/react-quick-modal'; // Step 2
interface props {
additionalMessage: string;
}
export const InfoModal = (props: props): JSX.Element => {
return (
<Modal // Step 3
title="Some quick info"
>
What a nice modal! {props.additionalMessage} // Step 4
</Modal>
);
};
Name | Type | Required | Description | Default |
---|---|---|---|---|
title | string | true | The title for the modal | undefined |
cancelButton | ModalButton (as shown below) | false | The cancel button config | undefined |
confirmButton | ModalButton (as shown below) | false | The confirm button config | undefined |
size | 'sm', 'lg', 'xl' | false | The size of the modal | undefined |
Name | Type | Required | Description | Default |
---|---|---|---|---|
label | string | false | The content for the button | '' |
callback | () => void | false | The onClick callback | undefined |
variant | 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light', 'link', 'outline-primary', 'outline-secondary', 'outline-success', 'outline-danger', 'outline-warning', 'outline-info', 'outline-dark', 'outline-light' | false | The button type | primary for confirm and secondary for cancle |
useModal
in the component where you want to create a modalInfoModal
import React from 'react';
import './info-modal'; // Step 2
import {withModal, ModalPropsWith} from '@scrumble-nl/react-quick-modal'; // Step 1
const MyComponent = (): JSX.Element => {
const {showModal, hideModal} = useModal();
const toggleModal = (): void => {
// Step 3
showModal(InfoModal, {
additionalMessage: 'My first modal',
});
}
return (
<button onClick={toggleModal}>Show my awesome modal</button>
)
}
withModal
in the component where you want to create a modalModalPropsWith
and extend it for your props interfaceexport default withModal(MyComponent)
to the fileInfoModal
import React from 'react';
import './info-modal'; // Step 4
import {withModal, ModalPropsWith} from '@scrumble-nl/react-quick-modal'; // Step 1 (& 2)
class MyComponent extends React.Component<ModalPropsWith, {}> {
showModal = (): void => {
// Step 5
this.props.modal.showModal(InfoModal, {
additionalMessage: 'My first modal',
});
}
render = (): JSX.Element => {
return (
<button onClick={this.showModal}>Show my awesome modal</button>
)
}
}
export default withModal(MyComponent); // Step 3
Next to that you can override the classes .modal-content
, .modal-header
, .modal-body
, and .modal-footer
to change the look of the modal.
If you would like to see additions/changes to this package you are always welcome to add some code or improve it.
This product has been originally developed by Scrumble for internal use. As we have been using lots of open source packages we wanted to give back to the community. We hope this helps you getting forward as much as other people helped us!
FAQs
A quick and easy wrapper around react-bootstrap modal, you can add or remove a modal from anywhere in your application with a few simple steps.
We found that @scrumble-nl/react-quick-modal demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.