Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.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
Javascript Firebase SigninsAccess WithAuthResult函数为空_Javascript_Reactjs_Firebase_Firebase Authentication_This - Fatal编程技术网

Javascript Firebase SigninsAccess WithAuthResult函数为空

Javascript Firebase SigninsAccess WithAuthResult函数为空,javascript,reactjs,firebase,firebase-authentication,this,Javascript,Reactjs,Firebase,Firebase Authentication,This,我正在通过Google auth登录Firebase。当用户执行此操作时,如果他们还没有帐户配置文件,则会在Firebase上创建并存储帐户配置文件。我遇到的问题是,当我尝试调用在“SignInsessWithAuthResult”中创建新用户的函数时,我得到一个错误,指出:“无法读取null的属性'registerNewFirebaseUser'。我是个新来的反应者,我认为这只是知识上的一个缺口。谢谢 callbacks: { signInSuccessWithAuthResult: fu

我正在通过Google auth登录Firebase。当用户执行此操作时,如果他们还没有帐户配置文件,则会在Firebase上创建并存储帐户配置文件。我遇到的问题是,当我尝试调用在“SignInsessWithAuthResult”中创建新用户的函数时,我得到一个错误,指出:“无法读取null的属性'registerNewFirebaseUser'。我是个新来的反应者,我认为这只是知识上的一个缺口。谢谢

callbacks: {
  signInSuccessWithAuthResult: function(authResult) {
    var userRef = fire.database().ref("/users")
    var currentUserID = firebase.auth().currentUser.uid;
    var userQuery = userRef.orderByChild("uid").equalTo(currentUserID);

    userQuery.once("value", function(snapshot) {
      if(snapshot.exists()) {
        window.location.pathname = '/artistList'
      } else {
        this.registerNewFirebaseUser();
      }
    })
    return false;
  }

registerNewFirebaseUser = () => {
  if (firebase.auth().currentUser !== null) {
   const userId = firebase.auth().currentUser.uid;
   const newUser = {uid: userId, votes_remaining: 5}
   this.userRef.push(newUser, function () {
    window.location.pathname = '/artistList';
  })
 }
}

看起来你的上下文可能有问题。这是针对您的函数而不是回调对象的。@TylerBurki感谢您的反馈Tyler,您对我的函数可能存在的问题有什么建议吗?就像我提到的,我是个新手,可能会错过一些简单的事情。谢谢