State does not unmount when changing screens and opens randomly ( react-navigation – firebase – react native-maps – giftedcha t)

Share on facebook
Share on google
Share on twitter
Share on linkedin

The screen states does not reset when navigating between screens.

Screen A: Map ( Main Screen ) Screen B : Map filters

When the user logs in he sees the main screen – Screen A – where on componentdidmount setState with the users in the firebase realtime db . To filter the map he goes to Screen B where he sets the filters, and the filters are saved to firebase. After the filters are saved he goes back to screen A, but the users in from the initial state are the same and to view the filtred list the user need to restart the app.

Having the same problem with giftedchat library and firebase when a user sends a message the chat screen opens randomly on the other users app and reopens even if the users are not chatting.

  • Tryed in both situations to put isMonted = true on componentdidmount and set it to false when leaving the screens , but with no success.

  • Tryed to setState when leaving the screen to all initaial states to false, also with no luck.

All the screens are on the same navigaton stack.

Using : -expo -firebase -react native navigation -react native maps -giftedchat

Is the any way to unmount the states when the user leaves the screen and prevent the screen from opening randomly?

submitted by /u/exodim
[link] [comments]

Sign up for our Newsletter

Agree to our privacy policy.