我正在尝试使用 react-redux-firebase (3.xx) 和 react-native-firebase v6 模块连接 redux 和 firebase。考虑到他们的v3 迁移指南,我正在关注react-redux-firebase 文档中的文档和示例,但似乎我无法让它工作。当我发送以下登录操作时,我收到错误:
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.