🌐
GitHub
github.com › eBay › nice-modal-react
GitHub - eBay/nice-modal-react: A modal state manager for React. · GitHub
This is a small, zero dependency utility to manage modals in a natural way for React.
Starred by 2.3K users
Forked by 127 users
Languages   TypeScript 57.7% | JavaScript 42.3%
🌐
Reddit
reddit.com › r/reactjs › managing modals in react (is there a way to have reactive modals with modal manager)?
r/reactjs on Reddit: Managing modals in React (is there a way to have reactive modals with modal manager)?
January 23, 2025 -

I've been feeling out different modal solutions trying to find the best way to handle them, but I'm thinking there has to be a better way that I'm missing.

The first way is just to store the modal directly in the page, and controlling visibility with an isOpen prop or similar. This works for modals that are specific to a single page, but it's kind of a pain because it's never quite clear where the modal JSX belongs.

The other solution would be to have a modal manager, which I thought was ideal. Just have a hook with openModal and closeModal functions, and set it up so that you can open them like so:

openModal('modalId', <Modal>{modalContent}</Modal>

It's super clean and works great, and I hadn't run into any issues with this approach until today.

The modal contains a form and I need to pass isPending state to the modal, so that I can display a loading spinner while the form's being submitted. But any state I pass in using openModal() isn't reactive, so there's seemingly no good way to handle this. I could use global state to update isPending when the mutation completes, but that feels kind of hacky and doesn't actually address the problem.

Is there a better way to handle modals where I don't have to choose between having a dynamic modal manager or having reactive state? Or is this just a tradeoff that's set in stone?

Thanks for the input

🌐
GitHub
github.com › whaoa › react-modal-manager
GitHub - whaoa/react-modal-manager: A lightweight modal manager for React.
A lightweight modal manager for React. Contribute to whaoa/react-modal-manager development by creating an account on GitHub.
Author   whaoa
🌐
DEV Community
dev.to › raotaohub › a-easy-modal-state-manager-for-react-1b8a
A easy modal state manager for React! - DEV Community
June 13, 2023 - */} ReactDOM.render( <EasyModal.Provider> // wrap your main Componet <App /> </EasyModal.Provider> document.getElementById('root'), ); ... import easyModal from 'ez-modal-react'; const InfoModal = EazyModal.create((props) => ( <Modal open={props.visible} onOk={props.hide} onCancel={props.hide}></Modal> ));
🌐
GitHub
github.com › VLZH › react-modal-manager
GitHub - VLZH/react-modal-manager: Manager of modal windows for react.
import React from "react"; import ReactDOM from "react-dom"; import Modal from "react-modal"; import { useModalManager, manager } from "@vlzh/react-modal-manager"; // subscribe on event 'afterOpen' manager.on("afterOpen", ({ modal_name }) => { console.log(`Modal ${modal_name} opened`); }); Modal.setAppElement("#root"); const OpenModalButton = () => { // if we do not define name in useModalManager this button will not be subscribed on changes in manager, but you must to define modal_name on calling of openModal const { openModal } = useModalManager(); return ( <button type="button" onClick={()
Author   VLZH
🌐
npm
npmjs.com › package › @saimin › react-modal-manager › v › 1.0.6
@saimin/react-modal-manager - npm
This is a customizable modal component library for React.js. It provides a flexible API to manage and display modals in your application.
      » npm install @saimin/react-modal-manager
    
Published   Sep 02, 2024
Version   1.0.6
Author   Sai Min
🌐
GitHub
github.com › RafaelSalguero › react-modal-manager
GitHub - RafaelSalguero/react-modal-manager: async/await modals with react · GitHub
class MyComponent extends React.Component { modalManager = createModalManager(); render() { return ( <div> {/*...*/} {modalManager.component} </div> ) } }
Starred by 3 users
Forked by 2 users
Languages   TypeScript 84.1% | JavaScript 11.9% | HTML 4.0%
Find elsewhere
🌐
Medium
medium.com › codex › 3-simple-custom-react-hooks-for-mastering-modal-management-cc9a6fc24937
3 Simple Custom React Hooks for Mastering Modal Management | by Andrew Richard | CodeX | Medium
May 18, 2024 - In this article, we will dive into three custom React hooks — `useModalManager`, `useClickOutside`, and `useModal` — that epitomize the hook philosophy. These tools encapsulate intricate behaviors in reusable, composable functions, allowing you to integrate sophisticated UI management into your projects with unparalleled ease. Effortlessly Juggle Multiple Modals with `useModalManager`
🌐
MUI
mui.com › material-ui › react-modal
React Modal component - Material UI
The component renders its children node in front of a backdrop component. The Modal offers important features: 💄 Manages modal stacking when one-at-a-time just isn't enough.
🌐
npm
npmjs.com › package › @vlzh › react-modal-manager
@vlzh/react-modal-manager - npm
September 11, 2020 - import React from "react"; import ReactDOM from "react-dom"; import Modal from "react-modal"; import { useModalManager, manager } from "@vlzh/react-modal-manager"; // subscribe on event 'afterOpen' manager.on("afterOpen", ({ modal_name }) => { console.log(`Modal ${modal_name} opened`); }); Modal.setAppElement("#root"); const OpenModalButton = () => { // if we do not define name in useModalManager this button will not be subscribed on changes in manager, but you must to define modal_name on calling of openModal const { openModal } = useModalManager(); return ( <button type="button" onClick={()
      » npm install @vlzh/react-modal-manager
    
Published   Sep 11, 2020
Version   2.0.0-alpha.4
Author   vlzh
🌐
npm
npmjs.com › package › react-modal-manager
react-modal-manager - npm
October 2, 2017 - Manage react modals with async functions. Latest version: 1.0.1, last published: 8 years ago. Start using react-modal-manager in your project by running `npm i react-modal-manager`. There are 1 other projects in the npm registry using react-modal-manager.
      » npm install react-modal-manager
    
Published   Oct 02, 2017
Version   1.0.1
Author   Rafael Salguero Iturrios
🌐
npm
npmjs.com › package › @jswork › react-modal-manager
@jswork/react-modal-manager - npm
import React from 'react'; import ReactModalManager from '@jswork/react-modal-manager'; import styled from 'styled-components'; import viteRequireContext from '@jswork/vite-require-context'; import '@jswork/next'; const Container = styled.div` width: 80%; margin: 30px auto 0; `; const moduleFiles = import.meta.globEager('./modals/*.jsx'); const context = viteRequireContext(moduleFiles); export default () => { return ( <Container> <ReactModalManager context={context} inject={(e) => { nx.$modal = e; }}> <button onClick={() => { nx.$modal.present('modal1'); }}> MyModal </button> </ReactModalManager> </Container> ); };
      » npm install @jswork/react-modal-manager
    
Published   Sep 11, 2024
Version   1.2.15
Homepage   https://js.work
🌐
LogRocket
blog.logrocket.com › home › improve modal management in react with nice-modal-react
Improve modal management in React with nice-modal-react - LogRocket Blog
June 4, 2024 - Every modal will have a cancel button next to the save/delete to close the modal. Don't miss a moment with The Replay, a curated newsletter from LogRocket · Learn how LogRocket's Galileo AI watches sessions for you and proactively surfaces the highest-impact things you should work on · Use React's useEffect to optimize your application's performance
🌐
CodeSandbox
codesandbox.io › s › react-modal-manager-ytyku
react-modal-manager - CodeSandbox
June 5, 2020 - react-modal-manager by VLZH using @vlzh/react-modal-manager, react, react-dom, react-modal, react-scripts
Published   Sep 24, 2019
Author   VLZH
🌐
Medium
medium.com › @gippi122221 › building-a-scalable-type-safe-modal-manager-in-react-with-mobx-d339be56b434
Building a Scalable, Type‑Safe Modal Manager in React with MobX | by Gennadii Garshin | Medium
July 22, 2025 - Learn how to build a scalable, type-safe modal manager in React using MobX. Centralized control, no prop drilling, and clean code.
🌐
Reddit
reddit.com › r/reactjs › a guide to managing modals in react.
r/reactjs on Reddit: A guide to managing modals in react.
January 17, 2023 - This checks if the user clicks (with a mouse or on a touchscreen) on the modal. If so, it just returns. If not, it calls the callback function. The return at the bottom of the useEffect cleans up the event listeners preventing memory leaks and stacking listeners. ... Very clever solution, my only worry would be the performance in the long term. Loved the creativeness! ... This is trashy as hell. You can pass an actual component into `openModal` (ie ReactNode).
🌐
HackerNoon
hackernoon.com › mastering-modal-dialogs-in-react-like-a-pro
Mastering Modal Dialogs in React Like a Pro | HackerNoon
February 23, 2024 - Explore a structured approach leveraging hooks, context, lazy loading, and Suspense for efficient and scalable dialog integration in React applications.
🌐
eBay Inc.
tech.ebayinc.com › engineering › rethink-modals-management-in-react
Rethink Modals Management in React - eBay Tech Blog
March 18, 2025 - The useModal hook returns a modal handler to manage modal state with an intuitive API. You can close the modal in the modal component itself without need to maintain the visibility state out of the component.
🌐
Opensource.com
opensource.com › article › 21 › 5 › global-modals-react
4 steps to set up global modals in React | Opensource.com
In my opinion, the best way to manage modal dialogs in your React application is globally by using a React context rather than a local state.
🌐
Npm
npm.io › package › @vlzh › react-modal-manager
@vlzh/react-modal-manager NPM | npm.io
import React from "react"; import ReactDOM from "react-dom"; import Modal from "react-modal"; import { useModalManager, manager } from "@vlzh/react-modal-manager"; // subscribe on event 'afterOpen' manager.on("afterOpen", ({ modal_name }) => { console.log(`Modal ${modal_name} opened`); }); Modal.setAppElement("#root"); const OpenModalButton = () => { // if we do not define name in useModalManager this button will not be subscribed on changes in manager, but you must to define modal_name on calling of openModal const { openModal } = useModalManager(); return ( <button type="button" onClick={()