colorfy-software / react-native-modalfy

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

Question: is it safe / possible to close a modal from within it? #151

Closed bryce-mcmath closed 3 months ago

bryce-mcmath commented 4 months ago

For example, within a modal component, can I use const { closeAllModals } = useModal() and then call closeAllModals() when some action is performed in that modal?

Thank you so much for this wonderful library! Appreciate any help

CharlesMangwa commented 3 months ago

hey @bryce-mcmath!

thanks for the kind words, much appreciated!

regarding your question: yes, that's something you can do.

modalfy actually makes interacting with modals from a modal component even easier: each one of them automatically receives a modal object in their props, meaning no hooks needed!

here is an example of that with what you asked but with closeModal (the approach is the same with closeAllModals): https://colorfy-software.gitbook.io/react-native-modalfy/guides/opening-closing#id-2.-from-a-modal-component