0
votes

I am using react navigation {create stack navigator} and so many pages. When I press hardware back button it exits app instead of going back.

My friend said that it is may be because of firebase (which I use for autheticating (no db)). Version of firebase 5.3.1 and he gave advice to install 5.0.0 (I've tried npm install [email protected] --save, but it shows some errors and hence is not installed)

And I've asked many of my friends and hardware back button returns goBack, but not for me

What should I do? I've tried to use BackHandler but I'm confused,so it doesn't work

react 16.3.1

react native 0.55.2

react navigation 2.9.3

2

2 Answers

0
votes

Did you added an event listner with react navigation ?

Follow this link it's well detailed.

0
votes

The issue is with the npm firebase package. This issue can be fixed by changing the way you import firebase. Use:

import firebase from "@firebase/app";
import "firebase/auth";
import "firebase/database";

Don't use import * as firebase from "firebase"; or import firebase from "firebase";

See this GitHub issue for more details.