
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
react-dialogs-container
Advanced tools
Lightweight hooks-ready library for managing dialogs in React applications.
npm i react-dialogs-container
DialogsProviderDialogsContainer component inside the providerimport {
DialogsContainer,
DialogsProvider,
useDialogs,
} from "react-dialogs-container";
const App = () => {
const { pushDialog } = useDialogs();
const handleOpenModal = () => {
pushDialog(ModalComponent, { title: "My Dialog" });
};
return (
<button onClick={handleOpenModal}>
Open Dialog
</button>
);
};
const Root = () => (
<DialogsProvider>
<App />
<DialogsContainer />
</DialogsProvider>
);
import { useDialogs } from "react-dialogs-container";
const MyDialog = ({ closeDialog, message }) => {
return (
<div className="modal">
<div className="modal-content">
<p>{message}</p>
<button onClick={closeDialog}>Close</button>
</div>
</div>
);
};
const App = () => {
const { pushDialog } = useDialogs();
return (
<button onClick={() => pushDialog(MyDialog, { message: "Hello!" })}>
Open Dialog
</button>
);
};
import React from "react";
import { useDialogs } from "react-dialogs-container";
const App = () => {
const { pushDialog } = useDialogs();
const handleClick = () => {
pushDialog(
React.createElement(MyDialog, { message: "Dialog from element" }),
);
};
return <button onClick={handleClick}>Open</button>;
};
import { useDialogs } from "react-dialogs-container";
const MyDialog = ({ closeDialog, title }) => {
return (
<div className="modal">
<h2>{title}</h2>
<button onClick={closeDialog}>Close</button>
</div>
);
};
const App = () => {
const { pushDialog } = useDialogs();
const handleClick = () => {
// Можно передать компонент напрямую как JSX элемент
pushDialog(<MyDialog title="My Dialog" />);
};
return <button onClick={handleClick}>Open Dialog</button>;
};
import { useDialog } from "react-dialogs-container";
const MyDialog = ({ title }) => {
const { closeDialog } = useDialog();
return (
<div className="modal">
<h2>{title}</h2>
<button onClick={closeDialog}>Close</button>
</div>
);
};
const App = () => {
const { pushDialog } = useDialogs();
const handleOpen = () => {
const closeDialog = pushDialog(MyDialog, { title: "Dialog" });
// Close dialog programmatically
setTimeout(() => {
closeDialog();
}, 3000);
};
return <button onClick={handleOpen}>Open with Auto-Close</button>;
};
import { useDialogs } from "react-dialogs-container";
const App = () => {
const { pushTempDialog } = useDialogs();
const handleOpen = () => {
// Dialog will automatically close when component unmounts
pushTempDialog(MyDialog, { title: "Temporary Dialog" });
};
return <button onClick={handleOpen}>Open Temporary Dialog</button>;
};
DialogsProviderContext provider for managing dialogs. Should wrap your application.
Props:
children: ReactNode - child elementsDialogsContainerComponent for rendering all active dialogs. Should be placed inside
DialogsProvider.
useDialogsMain hook for managing dialogs.
Returns:
pushDialog(component, props?): CloseDialogFn - opens a new dialog
component: ComponentType<DialogProps> | ReactElement - component, React
element, or JSX element (e.g., <MyDialog />)props?: Record<string, any> - props for the component (ignored if
component is already a ReactElement)closeDialogByID(dialogID: number): void - closes dialog by IDpushTempDialog(component, props?): CloseDialogFn - opens a temporary dialog
(automatically closes when component unmounts)useDialogHook for accessing dialog methods from inside a dialog component.
Returns:
closeDialog(): void - function to close the current dialoginterface DialogProps {
closeDialog: () => void;
[key: string]: any;
}
type CloseDialogFn = () => void;
interface DialogItem {
component: ComponentType<DialogProps> | ReactElement;
props: Record<string, any>;
dialogID: number;
}
MIT
FAQs
Lightweight hooks ready dialogs management
We found that react-dialogs-container demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.