
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
mui-modal-provider
Advanced tools
[](https://www.npmjs.com/package/mui-modal-provider) [](https://www.npmjs.
MUI-modal-provider is a helper based on Context API and React Hooks for simplified work with modals (dialogs) built on Material-UI or custom solutions with suitable props.
npm install mui-modal-provider # or yarn add mui-modal-provider
import React from 'react';
import ReactDOM from 'react-dom';
import ModalProvider, { useModal } from 'mui-modal-provider';
import DialogTitle from '@material-ui/core/DialogTitle';
import DialogContent from '@material-ui/core/DialogContent';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContentText from '@material-ui/core/DialogContentText';
import Dialog from '@material-ui/core/Dialog';
import Button from '@material-ui/core/Button';
const HelloWorldDialog = ({
title,
description,
onCancel,
onConfirm,
...props
}) => (
<Dialog open={false} {...props}>
<DialogTitle>{title}</DialogTitle>
<DialogContent>
<DialogContentText>{description}</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={onCancel} color="primary">
Cancel
</Button>
<Button onClick={onConfirm} color="primary">
Ok
</Button>
</DialogActions>
</Dialog>
);
const Demo = () => {
const { showModal } = useModal();
const handleClick = () => {
let timeoutId;
// Show `HelloWorldDialog` with initial props
const modal = showModal(HelloWorldDialog, {
title: 'Hello World',
description: 'description text',
onConfirm: () => modal.hide(),
onCancel: () => modal.hide(),
onExited: () => {
// =========================
// ⚠️ Be careful with setImmediate, setInterval and setTimeout
// ⚠️ don't forget to clean up id after closing dialog.
// ⚠️ use `onExited` or `onClose` callback for this.
// =========================
clearTimeout(timeoutId);
}
});
// Updating props if needed.
timeoutId = setTimeout(() => {
modal.update({
title: 'Updated hello world',
description: 'updated description text',
});
}, 1000);
};
return (
<Button
variant="contained"
onClick={handleClick}
color="primary"
>
show modal
</Button>
)
}
const App = () => (
<ModalProvider>
<Demo />
</ModalProvider>
);
ReactDOM.render(<App />, document.getElementById('root'));
FAQs
[](https://codecov.io/gh/Quernest/mui-modal-provider) [](h
The npm package mui-modal-provider receives a total of 16,486 weekly downloads. As such, mui-modal-provider popularity was classified as popular.
We found that mui-modal-provider demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.