redux-thunk异步操作未调度

时间:2019-03-20 05:05:46

标签: react-native redux redux-thunk

在loginUser操作的情况下,我的异步actoin不调度任何内容 而reasetPassword可以正常工作。两者都具有相同的代码,但是即使我派遣actoin loginUser,它也会卡在firebase.auth()中,而当它解析时,它永远都不会进入.then fucntion

但是当调度actoin时,resetPassword可以正常工作,它重新处理frebase.auth(),然后转到.then然后转到reducer

而loginUser被困在firebase.auth()。signinwithusername和password永远不会进入。然后,直到我再次触摸屏幕,然后它才到达派遣acton

export const loginUser = (email, password) => {
    return (dispatch) => {
        firebase
            .auth()
            .signInWithEmailAndPassword(email, password)
            .then((auth) => {
                dispatch({ type: actionTypes.LOGIN_SUCCESS, payload: auth });
            })
            .catch(function (err) {
                alert(err);
            });
    };
};


export const resetPassword = (email) => {
    return (dispatch) => {
        firebase
            .auth()
            .sendPasswordResetEmail(email)
            .then(() => {
                dispatch({ type: actionTypes.RESET_PASSWORD_REQUEST, payload: email });
                Alert.alert('Password reset link has been sent to the email: ' + email);
            })
            .catch(function (err) {
                alert(err);
            });
    };
};

This is the picture of my UserAction file

0 个答案:

没有答案