【发布时间】:2017-03-13 04:02:28
【问题描述】:
在我的 React Native 应用程序中,我只是登录用户或创建帐户,但即使用户成功登录或成功添加到数据库,我的登录和注册功能的 catch 块也会始终执行。所以这意味着success块(then)和catch块都是背靠背执行的。
除了 catch 块错误之外,我还看到一些黄色框警告说我的 JS 相对于 TextInput 组件太慢了。我不知道这些是否与 catch 块问题有关。
这个错误也影响了其他人,但我还没有听说有人找到解决方案。我已经在邮递员中测试了我的登录和注册路线,它们按预期工作,没有问题。
这里是登录和注册操作创建者:
登录:
export const loginUser = ({ email, password }) => {
const props = { email, password };
return (dispatch) => {
// notifies REDUX store that an ajax request is in progress
dispatch({ type: types.LOGIN_USER_START });
axios.post('http://localhost:3000/signin', props)
.then(user => loginUserSuccess(dispatch, user))
.catch(() => loginUserFail(dispatch));
};
};
注册:
export const signupUser = ({ email, password }) => {
const props = { email, password };
return (dispatch) => {
// notifies REDUX store that an ajax request is in progress
dispatch({ type: types.SIGNUP_USER_START });
axios.post('http://localhost:3000/signup', props)
.then(user => signupUserSuccess(dispatch, user))
.catch(() => {
signupUserFailed(dispatch);
});
};
};
【问题讨论】:
-
嘿,你能发布完整的错误日志吗?
标签: react-native ios-simulator redux