简体   繁体   中英

'firebase' is not defined no-undef

I was building a sign in page with firebase authentication using Google and Facebook. Kindly find the code snippet and error message below.

import {GoogleOutlined,FacebookOutlined} from '@ant-design/icons';
import {auth} from '../firebase';
import "firebase/app";


const Login = () => {
   
    
    return (
   
   <div id="login-page"> 
            <div id="login-card">
               
               <h2>Welcome to PryChat !</h2>

               <div className="login-button google"
               onClick={()=>auth.signInWithRedirect(new firebase.auth.GoogleAuthProvider())}>

<GoogleOutlined /> Sign In with Google 
               </div>

<br></br>

<div className="login-button facebook" onClick={()=>auth.signInWithRedirect(new firebase.auth.FacebookAuthProvider())}>
<FacebookOutlined /> Sign In with Facebook 
               
               </div>
            </div>
   </div>
   
   );
}

export default Login

在此处输入图像描述

I can't comment but have you installed the correct version of firebase? If you have v9 installed (the latest, modular version) it probably isn't working because you're using the v8 syntax.

Try looking at the v9 syntax in the documentation for Google and Facebook and make sure you use the correct version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM