'Google sign in with Firebase 09 : signInWithPopup and signInWithRedirect return an undefined error

Here is the authcontext import and code

import {signInWithPopup, GoogleAuthProvider, createUserWithEmailAndPassword, getAuth, onAuthStateChanged, signInWithEmailAndPassword, signOut, signInWithRedirect} from 'firebase/auth'; 
 //google login 
    const signInwithGoogle = ()=>{
        const provider = new GoogleAuthProvider()    
        
        console.log(provider)
        // return signInWithPopup(auth, provider);

        signInWithPopup(auth, provider)
        .then((result) => {
            // This gives you a Google Access Token. You can use it to access the Google API.
            const credential = GoogleAuthProvider.credentialFromResult(result);
            const token = credential.accessToken;
            // The signed-in user info.
            const user = result.user;
            setUser(user)
            console.log(result)
            // ...
        }).catch((error) => {
            // Handle Errors here.
            const errorCode = error.code;
            const errorMessage = error.message;
            // The email of the user's account used.
            const email = error.email;
            // The AuthCredential type that was used.
            const credential = GoogleAuthProvider.credentialFromError(error);
            // ...
            console.log(errorMessage)
        });

    }
    

And it returns the following error

TypeError: (0, _auth.signInWithPopup) is not a function. (In '(0, _auth.signInWithPopup)(auth, provider)', '(0, _auth.signInWithPopup)' is undefined)

I have working code for sign in with email and password. Also, I have enabled firebase authentication for login with gmail. It seems like there's no logical error.

I tried using signInWithRedirect(auth, provider); and it return the same error. Also I have import getAuth as well



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source