reactjs - 用redux反应导航不起作用
问题描述
我想从我的动作 js 文件中更改路由,所以结合到根 Reducer 的 navReducer.js 是
const router = RootStack.router;
const initialState = router.getStateForAction(NavigationActions.init());
export default navReducer = (state = initialState, action) => {
return router.getStateForAction(action, state);
}
而连接到reducer的mainRoute.js是
const SiraRoute = (props) => (
<RootStack navigation={{
dispatch: props.dispatch,
state: props.nav,
}}
/>
)
const mapStateToProps = (state) => ({
nav: state.navReducer,
});
export default connect(mapStateToProps)(SiraRoute);
index.js 文件是
const store = configureStore();
const sira = () => (
<Provider store={store}>
<SiraRoute />
</Provider>
)
AppRegistry.registerComponent('SIRA', () => sira);
但我得到navigation.getChildNavigation 不是函数错误。
- 反应导航:^2.0.1
- 反应原生:0.55.3
解决方案
这可能与 React Navigation 正在放弃对 redux 的支持有关。
警告:在 2018 年秋季发布的下一个主要版本的 React Navigation 中,我们将不再提供有关如何与 Redux 集成的任何信息,并且它可能会停止工作。
关于如何在反应导航中从 Redux 迁移的讨论: https ://github.com/react-navigation/react-navigation/issues/4490
推荐阅读
- python - Django 的 AWS Elastic Beanstalk 500 内部服务器错误
- php - 与 PayPal-PHP-SDK 的订阅集成
- javascript - 限制同一页面内的垂直/水平滚动方向
- .net - 如何从通用 Windows 项目中引用 .NET Framework 4.6 类库?
- php - 如何在 img 标签中查看 src 的多个地址?
- arrays - Swift将数组中的随机元素返回到文本中
- jar - 如何使用 Sonatype Nexus 存储库中的 maven pom 文件下载第三方 jar 文件
- c# - WPF 绑定到具有列表视图列参数的方法结果
- c++ - 谁能告诉我我的 C++ 代码有什么问题?
- c++ - 指针类型类成员的动态转换的 const-ness 是什么