Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs TypeError:firebase.auth.GoogleAuthProvider不是构造函数_Reactjs_Firebase_Google Authentication - Fatal编程技术网

Reactjs TypeError:firebase.auth.GoogleAuthProvider不是构造函数

Reactjs TypeError:firebase.auth.GoogleAuthProvider不是构造函数,reactjs,firebase,google-authentication,Reactjs,Firebase,Google Authentication,我正在构建一个react应用程序,我想使用firebase集成google signin。在实现它的过程中,我遵循了firebase文档,但我一直遇到这样的错误——“TypeError:firebase.auth.GoogleAuthProvider不是构造函数”。 这是我的密码 firebase.prod.js import Firebase from "firebase/app"; import "firebase/firestore"; import

我正在构建一个react应用程序,我想使用firebase集成google signin。在实现它的过程中,我遵循了firebase文档,但我一直遇到这样的错误——“TypeError:firebase.auth.GoogleAuthProvider不是构造函数”。 这是我的密码

firebase.prod.js

import Firebase from "firebase/app";
import "firebase/firestore";
import "firebase/auth";
import "firebase/storage";

const config = {
  apiKey: "AIzaSyASOat6CaIWxzwnepoGBHDpltnf9jH1QH0",
  authDomain: "cv-builder-c0429.firebaseapp.com",
  databaseURL: "https://cv-builder-c0429.firebaseio.com",
  storageBucket: "cv-builder-c0429.appspot.com",
};

const firebase = Firebase.initializeApp(config);

export { firebase };
签名

import React, { useState, useContext } from "react";
import { FirebaseContext } from "../context/firebase";

export default function SignUp() {
  const { firebase } = useContext(FirebaseContext);

  const googleSignIn = () => {
    var provider = new firebase.auth.GoogleAuthProvider();
      provider.addScope('profile');
      provider.addScope('email');

      firebase.auth()
      .signInWithPopup(provider)
      .then((result) => {
        console.log(result)
      }).catch((error) => {
        console.log(error);
      });
  };
 
  return (
    <button onClick={googleSignIn}>Sign in with google</button>
  )
};
import React,{useState,useContext}来自“React”;
从“./context/firebase”导入{FirebaseContext};
导出默认函数注册(){
const{firebase}=useContext(FirebaseContext);
const googleSignIn=()=>{
var provider=new firebase.auth.GoogleAuthProvider();
provider.addScope(“profile”);
provider.addScope(“电子邮件”);
firebase.auth()
.signInWithPopup(提供程序)
。然后((结果)=>{
console.log(结果)
}).catch((错误)=>{
console.log(错误);
});
};
返回(
使用谷歌登录
)
};

如果您能帮助我们解决此问题,我们将不胜感激。

您能将我们链接到文档中我们可以找到此代码的位置吗?您是指GitHub回购协议吗?哦,那会有帮助的。但我说的是官方文档的一部分,你说你是从那里得到这段代码的。在那个网站上,在“创建Google provider对象的实例”下的“代码”框中:如果我从v8切换到v9,它将不再向你显示
new firebase.auth.GoogleAuthProvider()语法。你可能在v9上吗?(他们写道,v9的设计更加模块化,可能因此他们停止了导出
GoogleAuthProvider()
default。)无论如何,如果您还没有尝试v9语法,您应该在那里尝试。