DEV Community

Dragos11
Dragos11

Posted on

React-Native Modals Problems

Ok, the problem is the following one: I try to render a modal that has a loader (ActivityIndicator as the native-component) and it is preceded by an Alert.

The modal is showed while the call to the API is on loading and the response hasn't arrived. When the response has come the Alert is rendered. For some reasons the ios closes the alert immediately and the modal with the loader remains on the screen forever. You have to close the app in order to get rid of it.

After some documentation I found that the alert native component is deep inside a modal and I think that the iOS loses track of the modals he has to close. After some brainstorming with some better developers than me(almost everyone) we found a solution: SetTimeOut(), even with 0(practically instant) so the iOS has time to decide what modals to close. Happy Happy, Joy Joy for about 2 or 3 days when we tested the app on some devices. The devices can't close the modals as it should. So I decided to look better on the dearest friend of man, the internet. I tried looking if react-native offers an onModalClose method and I found out that there was such a method, but only on the rc. So the only chance is to wait for the next release. Come on REACT :D

Top comments (1)

Collapse
 
lookagit profile image
Luka Simjanovic

I have similiar problem with modal when i press touchable opacity in modal and keboard is up my app ends with white screen. I used setTimeout like you and its all good now. That problem didnt occure until i changed react native router flux with RRV4 :D