Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

343
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda