我正在尝试使用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.
import firebase from 'firebase';
...
onLogin = async (user, success_callback, failed_callback) => {
await firebase.auth()
.signInWithEmailAndPassword(user.email, user.password)
.then(success_callback, failed_callback);
}
为我工作]