closeAllModals() and others sometimes do not run
See original GitHub issueIssue Description
I’ve updated to the latest 3.3.0 release. But now I’m seeing another issue.
In my app, when I navigate the user to another screen, I like to close all open modals (sometimes the user is navigated due to a change in data, for example where they are being attacked by another player, so I need to react to it).
I’m seeing intermittent behavior where closeAllModals() is not being run at all though. I’ve passed in a logging callback, and usually I don’t see that logged, and the modal stays open on top of the navigation change below the modal, so the user doesn’t notice they are being attacked.
I even log currentModal immediately before to check if there is a currentModal open, and it is correct. Any ideas?
const navToAttack = async () => {
props.navigation.navigate("attack", {
attackId: user.attackId
})
console.log(currentModal)
closeAllModals(() => {
console.log('closed all')
})
}
When the modal stays open occasionally, I just see the currentModal logged, but no callback logging:
MainMenuModal
Where in the code could I manually do some logging in your plugin to help troubleshoot? I tried adding logging to both files’ functions and rebuilding, but I never see the added statement logged: node_modules\react-native-modalfy\lib\commonjs\lib\ModalState.js node_modules\react-native-modalfy\lib\module\lib\ModalState.js
const closeAllModals = () => {
console.log('test closeAllModals')
const {
openedItems
} = state.stack;
openedItems.clear();
setState(currentState => ({
currentModal: null,
stack: { ...currentState.stack,
openedItems
}
}));
};
Thanks for any help in troubleshooting this issue!
Issue Analytics
- State:
- Created 9 months ago
- Comments:13 (3 by maintainers)
I tried to replicate this error in a snack, but couldn’t. I will check my code again to see if im doing something wrong. I will post if I find out anything. Thanks
Hey @otaviogaiao! Did you try to invoke your callback as mentioned in the docs? If you can submit a repro on Snack, that’d be very helpful!