Code Monkey home page Code Monkey logo

Comments (4)

Quernest avatar Quernest commented on June 15, 2024

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.

WenLonG12345 avatar WenLonG12345 commented on June 15, 2024

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.

Quernest avatar Quernest commented on June 15, 2024

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.

WenLonG12345 avatar WenLonG12345 commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.