react-native - 将 Redux 与 ReactNavigation 集成时,mapStateToProps() 返回未定义
问题描述
我目前正在处理两个屏幕:Login 和 EmployeeList,并且没有设置 initialRouteName。
我结合了两个减速器:NavReducer 和 AuthReducer。我在 LoginForm 中接收 state.auth,在 RouterWithNavigationState 中接收 state.nav,如下所示:
class RouterWithNavigationState extends Component{
...
<Router navigation = {addNavigationHelpers({
dispatch: this.props.dispatch,
state: this.props.navigation
})} />
...
}
const mapStateToProps = state =>
{
console.log (state.nav)
return
{
navigation: state.nav
}
}
export default connect(mapStateToProps)(RouterWithNavigationState)
但是我得到一个错误:
(1)mapStateToProps() in Connect(RouterWithNavigationState) must return a plain object. Instead received undefined.
(2)addNavigationHelpers is not a function
日志语句打印我在 NavReducer.js 中定义的初始状态,如下所示:{index: 0, routes: Array(1)}
包.json:
"dependencies": {
"firebase": "^4.13.1",
"react": "16.3.1",
"react-native": "0.55.3",
"react-navigation": "^2.0.1",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"
}
我错过了什么?
解决方案
推荐阅读
- php - 构建应用程序后phonegap mysql插入不起作用
- amazon-web-services - 调用 UpdateSecret 操作时发生错误 (LimitExceededException):您超出了密钥的最大版本数
- typescript - 将对象发布到 http angular 6 时更改变量名称
- php - 如何在邮件功能中插入链接
- javascript - 如何将 MDC web javascript(如 MDCRipple)应用于已使用 AJAX 加载的内容
- react-native - 找不到变量:在屏幕之间导航
- modelica - 如何将 Revit 属性转移到 openmodelica?
- javascript - 在树视图 Odoo 中单击时禁用日期选择器
- sapui5 - 为什么byId找不到控件?
- eloquent - 图像不验证大小