Comments (4)
Hi, thanks for this awesome library, however, I have some problem regarding to closing current modal and open another new one. Here is the example
const loginModal = showModal(LoginModal, { onClose: () => {}, onRedirectForgetPwd: () => {}, onRedirectRegister: () => { loginModal.hide(); showModal(RegisterModal) }, }); const registerModal = showModal(RegisterModal, { onClose: () => {}, onRedirectLogin: () => { registerModal.hide(); showModal(LoginModal) }, });
onRedirectxxx
was indicated a callback funnction to trigger modal useState(). How can I archive this working? Any clues?
Hi @WenLonG12345, thank you for your comment.
But could you make an example on https://codesandbox.io/ ?
I tried to do the similar thing and it works well for me.
Maybe the problem is with the redirect? Maybe the page is reloaded and the callback doesn't fire?
from mui-modal-provider.
Hi @Quernest ,
I had create a codesandbox that related to my usecase, and also highlight my problem in there.
feel free to let me know if there is any doubt. Thanks :)
https://codesandbox.io/s/mui-modal-provider-multiple-modal-4psfth?file=/src/App.tsx
from mui-modal-provider.
Hi @Quernest , I had create a codesandbox that related to my usecase, and also highlight my problem in there. feel free to let me know if there is any doubt. Thanks :) https://codesandbox.io/s/mui-modal-provider-multiple-modal-4psfth?file=/src/App.tsx
https://codesandbox.io/s/mui-modal-provider-multiple-modal-forked-pl3x5p?file=/src/App.tsx
This code works well for me. You forgot to wrap the app in the ModalProvider.
useRef
is not necessary to use, it's just for convenience of global access.
You can use local const
without any problem.
from mui-modal-provider.
I disabled the ModalProvider because const
will cause infinite loop, and I have no idea why.
but I think useRef
is the solution that I wanted! Thanks for the guidance! 👍🏻
from mui-modal-provider.
Related Issues (20)
- 🐛 showModal hook returned by useModal is not properly memoized
- peerDeps issues HOT 1
- "Cannot read property 'props' of undefined" error if component unmounts before onClose is called HOT 1
- Nested dialog bug HOT 1
- Unhandled missed modal ID scenario
- MUI Dialog API changed HOT 2
- 🐛 Missing 'dist/modal.esm.js' in package HOT 2
- hideModal() from within Dialog component HOT 6
- Rerenders all components HOT 4
- Missing export for typescript types
- Support with React 18 HOT 1
- disableBackdropClick HOT 2
- Rendering a lazy-loaded dialog? HOT 2
- Do not destroy modal on component unmount HOT 5
- useModal is not a function HOT 2
- destroy is always called regardless of options. HOT 2
- Throw an error in case Provider not being used HOT 19
- Make it possible to disable provider check errors
- Disable closing on backdrop click HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mui-modal-provider.