Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Global' modal in React Native

Tags:

react-native

I'm building an app in React native, and basically, I need a modal(which will have the same content every time) to be available globally (in all components of app), so that I can be able to open it from anywhere in my app. Obviously copy/pasting the same modal in all the components is not a good solution Right now I'm having tons of trouble implementing it, so I would like to know what would be the best way to accomplish something like that

like image 889
Rene M. Avatar asked Jul 12 '26 01:07

Rene M.


1 Answers

Use a Navigator and place your modal below it. Make it visible only when the state changes. The state can be changed from each component inside the Navigator via props.navigator. You can see the full code with explanation here http://browniefed.com/blog/react-native-easy-overlay-modal-with-navigator/

like image 79
Orlando Avatar answered Jul 13 '26 17:07

Orlando



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!