在调度登录操作时,firebase.auth不是函数

时间:2019-10-26 15:32:45

标签: react-native react-redux react-native-firebase react-redux-firebase

我正在尝试使用react-redux-firebase(3.x.x)和react-native-firebase v6模块连接redux和firebase。我正在关注react-redux-firebase docs的文档和示例,并考虑了它们的v3 migration guide,但看来我无法使其正常工作。当我分派以下登录操作时,出现错误: TypeError: firebase.auth is not a function

Firebase应用程序是本地初始化的,当我创建商店时,我使用HOC ReactReduxFirebaseProvider。有人有类似的案子吗?

我尝试手动初始化firebase应用程序,但我想我的问题并非如此,因为我收到警告,提示默认应用程序已初始化。

谢谢。


export const login = credentials => {
  return (dispatch, getState, {getFirebase}) => {
    const firebase = getFirebase();
    // console.log(firebase);      <-- here i control firebase instance and it seems ok
    firebase
      .login(credentials)          <-- error is thrown
      .then(() => {
        dispatch({type: LOGIN_SUCCESS});
      })
      .catch(err => {
        dispatch({type: LOGIN_ERROR, err});
      });

    // OR
    // doesn't work either, throws the same error
    /* firebase
      .auth()                     <-- error is thrown
      .signInWithEmailAndPassword(credentials.email, credentials.password)
      .then(() => {
        dispatch({type: LOGIN_SUCCESS});
      })
      .catch(err => {
        dispatch({type: LOGIN_ERROR, err});
      }); */
  };
};

// It should return a promise instead of an error.

1 个答案:

答案 0 :(得分:0)

def append(self,message): 
    self.message.append(message)

为我工作