wix-incubator / react-popup-manager

Manage react popups, Modals, Lightboxes, Notifications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature] support default global manager.

lwyj123 opened this issue · comments

it's convenient to have a default global manager that can simply call open, closeAll without using Provider in practice. But developer can use provider to control different part of logic in advanced use case.

import {open, closeAll} from 'react-popup-manager'

// ...
open(MyModal, {title: 'my modal'})
closeAll()

or

import {globalManager} from 'react-popup-manager'

// ...
globalManager.open(MyModal, {title: 'my modal'})
globalManager.closeAll()

Hey @lwyj123,
There is a solution which is close to that using hooks

import React from "react";
import { usePopupManager } from "react-popup-manager";
import { MyModal } from './MyModal'

//...
const {open, closeAll} = usePopupManager();

Does that help?