I have a React Native App and have the following function:
import firebase from './firebase'
export function MainNavigator() {
const [token, setToken] = useAtom(tokenAtom);
useEffect(() => {
firebase.auth().onIdTokenChanged(async (user) => {
setToken(user ? await user.getIdToken() : null);
});
}, []);
.....
.... more code
This above code worked in Expo, but I have a new react native project (not built using expo) and this is failing:
I have the following in my package.json file:
"@react-native-firebase/app": "^13.0.1",
"@react-native-firebase/functions": "^13.0.1",
"firebase": "^9.5.0",
And my firebase.js file is like so (root directory)
import * as firebase from "firebase/app";
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "Secret stuff",
authDomain: "Secret stuff",
databaseURL: "Secret stuff",
projectId: "Secret stuff",
storageBucket: "Secret stuff",
messagingSenderId: "Secret stuff",
appId: "Secret stuff",
measurementId: "Secret stuff"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
export default firebase;
Im getting the following error:
TypeError: _firebase.default.auth is not a function. (In '_firebase.default.auth()', '_firebase.default.auth' is undefined)