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

314
Vistas
TypeError: _app.default.auth is not a function - React Native Web - Firebase

I am currently developing a project on React Native Web and this is my login call in a component. (The call is in the components useEffect, as soon as the component opens, it should log in anonymously)

import firebase from 'firebase/compat/app'
import 'firebase/compat/auth'
const firebaseConfig = {
        apiKey: "****",
        authDomain: "****",
        projectId: "****",
        storageBucket: "****",
        messagingSenderId: "****",
        appId: "****",
        measurementId: "****"
      };
      firebase.initializeApp(firebaseConfig) 

const login = async () => {
        firebase.auth().signInAnonymously() 
            .then((userCredential) => {
                // Signed in
                // ...
              })
              .catch((error) => {
                console.log("LOG: "+error)
              });
    } 

But everytime I get the error: Uncaught (in promise) TypeError: _app.default.auth is not a function

I tried several different imports, but none of them seemed to work. I see the error when I open the Console on Firefox. How can I fix this issue?

Thanks

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

0

Try this approach by checking if firebase is initialized and the user is not logged in:

const [loggedIn, setLoggedIn] = React.useState(false)

React.useEffect(() => {
    if (!firebase.apps.length) {
        firebase.initializeApp({
            apiKey: "****",
            authDomain: "****",
            projectId: "****",
            storageBucket: "****",
            messagingSenderId: "****",
            appId: "****",
            measurementId: "****"
        });
    }
}, [])

React.useEffect(() => {
    if (firebase.apps.length && !loggedIn) {
        setLoggedIn(true)
        login()
    }
}, [firebase])

const login = async () => {
    firebase.auth().signInAnonymously()
        .then((userCredential) => {
            // Signed in
            // ...
        })
        .catch((error) => {
            console.log("LOG: " + error)
        });
} 
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