我试图在我的RN应用中对redux使用反应导航。我有一个登录按钮,其按钮按下功能如下:
onButtonPress() {
const { email, password } = this.props;
this.props.loginUser({ email, password })
.then(() => {
this.props.navigate('Home');
});
}
loginUser是一个由redux调度的操作,但是按一下此按钮功能却在我的loginform组件中,该组件在主堆栈导航器中用作我的屏幕之一,并且我已经对其进行了测试以确保其正常工作,但是,无论何时添加导航功能,我都会不断收到此错误: undefined不是对象(评估'this.props.loginUser({电子邮件:电子邮件,密码:密码})。然后')
但是,如果我在then语句之外有导航语句,则它可以工作。我尝试查看关于stackoverflow和github的其他问题,但没有找到有效的解决方案,有帮助吗?
这是我在登录日志(this.props)时得到的信息:
Object { "email": "n*********@gmail.com", "emailChanged": [Function anonymous], "error": "", "loading": false, "loginUser": [Function anonymous], "navigation": Object { "actions": Object { "dismiss": [Function dismiss], "goBack": [Function goBack], "navigate": [Function navigate], "pop": [Function pop], "popToTop": [Function popToTop], "push": [Function push], "replace": [Function replace], "reset": [Function reset], "setParams": [Function setParams], }, "addListener": [Function addListener], "dangerouslyGetParent": [Function anonymous], "dismiss": [Function anonymous], "dispatch": [Function anonymous], "getChildNavigation": [Function getChildNavigation], "getParam": [Function anonymous], "getScreenProps": [Function anonymous], "goBack": [Function anonymous], "isFocused": [Function isFocused], "navigate": [Function anonymous], "pop": [Function anonymous], "popToTop": [Function anonymous], "push": [Function anonymous], "replace": [Function anonymous], "reset": [Function anonymous], "router": undefined, "setParams": [Function anonymous], "state": Object { "key": "id-1532963235056-0", "routeName": "Login", }, }, "password": "******", "passwordChanged": [Function anonymous], "screenProps": undefined, "signUpUser": [Function anonymous], }
答案 0 :(得分:0)
你可以试试吗?
/api/items