Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

346
Vistas
React Native - TypeError: _firebase.default.auth is not a function

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)

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

None of the code you show imports the Firebase Authentication SDK. So when you then try to use firebase.auth() it correctly indicates that it can't find that SDK.

I'm guessing you want to import the Auth SDK too with something like:

import "firebase/auth";

I'd also recommend checking out the documentation on upgrading to the v9 or v9/compat SDK.

about 4 years ago · Juan Pablo Isaza Denunciar

0

// v9 compat packages are API compatible with v8 code

import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';

docs

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda