Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

477
Views
Firebase y React TypeError: firebase.auth(...).onAuthStateChanged no es una función

Estoy tratando de usar el activador onAuthStateChanged para cancelar la suscripción, pero sigo recibiendo:

TypeError no capturado: (0, firebase_util__WEBPACK_IMPORTED_MODULE_0 _.getModularInstance)(...). onAuthStateChanged no es una función a continuación es mi Authcontext.js

 import React ,{useEffect, useState ,useContext} from 'react'; import { auth } from '../api/firebase'; const AuthContext = React.createContext(); export function useAuth() { return useContext(AuthContext) } export function AuthProvider({ children }) { const [currentUser, setCurrentUser] = useState(null); const [loading,setLoading] = useState(true); function register (email,password) { return auth.createUserWithEmailAndPassword(email,password); } useEffect(() => { const unsubscribe = auth.onAuthStateChanged(user => { setCurrentUser(user); }); return unsubscribe; }, []); const value = { currentUser, register, } return ( <AuthContext.Provider value={value}> {children} </AuthContext.Provider> ); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No te estás suscribiendo al StateChange correctamente, prueba lo siguiente

 React.useEffect(() => { const unsubscribe = firebase.auth().onAuthStateChanged((user) => { // detaching the listener if (user) { // ...your code to handle authenticated users. } else { // No user is signed in...code to handle unauthenticated users. } }); return () => unsubscribe(); // unsubscribing from the listener when the component is unmounting. }, []);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!