I have a fully-managed app I’ve been building for some time on SDK41. I updated to SDK42 and had a problem, so I did a cleaned up the node_modules directory and did a fresh npm install. After that, the app started running but I cannot get the firebase.auth call to work — it comes up as undefined, and I haven’t changed anything there. Maybe in the course of the cleanup I wound up on a newer version of the firebase npm, but in any case, I’m stumped. My firestore has one collection that doesn’t need auth permissions, and it’s accessible, which tells me that firebase itself is getting initialized properly.
The code looks pretty vanilla:
import * as firebase from 'firebase'
import "firebase/firestore"
import "firebase/auth"
import { FirebaseConfig } from '../shared'
function RootNavigator() {
...
if (!firebase.apps.length) {
firebase.initializeApp(FirebaseConfig);
}
React.useEffect(() => {
firebase.auth().onAuthStateChanged((user) => {
authContext.userProfile = user
if (!user)
{
authContext.logInAnonymously()
}
});
}, []);
This is the error that gets thrown:
TypeError: firebase.auth is not a function. (In 'firebase.auth()', 'firebase.auth' is undefined)
This error is located at:
in RootNavigator (at navigation/index.tsx:31)
in EnsureSingleNavigator (at BaseNavigationContainer.tsx:409)
in ForwardRef(BaseNavigationContainer) (at NavigationContainer.tsx:91)
in ThemeProvider (at NavigationContainer.tsx:90)
in ForwardRef(NavigationContainer) (at navigation/index.tsx:28)
in Navigation (at App.tsx:22)
in RNCSafeAreaProvider (at SafeAreaContext.tsx:76)
in SafeAreaProvider (at App.tsx:21)
in App (created by ExpoRoot)
in ExpoRoot (at renderApplication.js:45)
in RCTView (at View.js:34)
in View (at AppContainer.js:106)
in RCTView (at View.js:34)
in View (at react-native-root-siblings/index.js:32)
in RootSiblingsWrapper (at AppContainer.js:121)
in RCTView (at View.js:34)
in View (at AppContainer.js:132)
in AppContainer (at renderApplication.js:39)
All of this was working prior to this update, but I don’t know what the connection would be to the SDK update.
SDK 42, both iOS/Android have this behavior.