connect and withRouter issue(connect 和 withRouter 问题)
问题描述
我在我的项目中使用 Redux 和 React.我在 App.js 中有一些路由.我还在我的项目中使用 react-redux 中的连接功能.为了防止更新阻塞问题,我通常以这种方式包装我的组件
I am using Redux and React for my project. I have some Routes in App.js. I also use the connect function in react-redux in my project. To prevent update blocking issue, I usually wrapped my component in this way
withRouter(connect(mapStateToProps, mapDispatchToProps)(App)),
但是,如果我更改了 withRouter 的顺序并连接它不起作用:
However, If I changed order of withRouter and connect it doesn't work:
connect(mapStateToProps, mapDispatchToProps)(withRouter(App))
我有 console.log App.js 中的道具.它已经接收到位置和历史道具.我正在弄清楚为什么顺序很重要背后的理论?
I have console.log the props in App.js. It already receives location and history props. I am figuring out the theory behind why the order does matter ?
推荐答案
可以参考一下这个https://reacttraining.com/react-router/core/api/withRouter,它清楚地表明它不能反过来工作
Could you refer to this https://reacttraining.com/react-router/core/api/withRouter, it clearly says that it doesn't work the other way around
这篇关于connect 和 withRouter 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:connect 和 withRouter 问题


基础教程推荐
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01