DEV Community

Dragos11
Dragos11

Posted on

5 1

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

Billboard image

Imagine monitoring that's actually built for developers

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

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

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay