colorfy-software / react-native-modalfy

🥞 Modal citizen of React Native.
https://colorfy-software.gitbook.io/react-native-modalfy
MIT License
1.06k stars 41 forks source link

Unable to open a new modal in closeAllModals callback unless you use a timeout hack #147

Open rossmartin opened 2 months ago

rossmartin commented 2 months ago

Hi, thank you for your work on this great project!

With version 3.5.3 we are unable to open a modal from within the callback for closeAllModals unless you use a timeout hack.

Here is a snippet that illustrates the problem:

closeAllModals(() => {
  // openModal does not work here in the callback
  openModal(name, options)
  // It does work if you wrap openModal in a micro timeout.
  // There seems to be a race condition happening somewhere.
})

I think this affects the callback for closeModal in the same way also.

I forked the repo here and added this snippet to the example app to illustrate the issue - https://github.com/rossmartin/react-native-modalfy/commit/a7a2abef15e498ad92795c9e3d7f04cc8874ef63

You should be able to reproduce the issue by the snippet or the forked example app provided.

CharlesMangwa commented 2 days ago

hey @rossmartin! thanks for opening this issue. i'll try to have a look at it and see what could be causing this: thanks for providing a repro 👍