Closed mist0616 closed 9 months ago
I'm currently facing this issue too. Any advice as to how to destroy all open dialogs would be most appreciated...
I'm currently facing this issue too. Any advice as to how to destroy all open dialogs would be most appreciated...
I solved this later by rewriting the useModal method...
You can use NiceModalContext
to get all modals' ids then hide them.
const modals = useContext(NiceModal.NiceModalContext);
It's in format of { [modalId]: args }
.
Below example code opens two modals, then close them in 3 seconds:
useEffect(() => {
NiceModal.show(MyAntdModal, { name: 'Nate' })
NiceModal.show(MyAntdDrawer, { name: 'Bood' })
}, [])
const modals = useContext(NiceModal.NiceModalContext);
useEffect(() => {
setTimeout(() => {
Object.keys(modals).forEach((mid) => { NiceModal.hide(mid) })
}, 3000);
}, [modals])
I want to destroy all the popups that are being displayed when the backend interface 401, how do I do that?