Javascript redux不';不能很好地使用react路由器v4
我有一个类似这样的事件Javascript redux不';不能很好地使用react路由器v4,javascript,reactjs,redux,Javascript,Reactjs,Redux,我有一个类似这样的事件 //src/App/components/common/Notifications onCommentClick = (id) => { this.props.history.push(`/dashboard/${id}`) } 它会改变浏览器的url,我想我的路线设置正确 //src/App/containers/dashboard/user/NotificationDetail 但问题是redux似乎没有重新发布我的容器组件,我需要刷新以获得正确的内
//src/App/components/common/Notifications
onCommentClick = (id) => {
this.props.history.push(`/dashboard/${id}`)
}
它会改变浏览器的url,我想我的路线设置正确
//src/App/containers/dashboard/user/NotificationDetail
但问题是redux似乎没有重新发布我的容器组件,我需要刷新以获得正确的内容
来源
坚持了一天,找不到解决方案。而不是这个->
@withRouter
@connect(state => state.global, {
getNotifications
})
使用MapStateTrops()
->
function mapStateToProps(state) {
notifications: state.notifications
}
function mapDispatchToProps(dispatch) {
// your actions here
}
export const NotificationsComponent = connect(mapStateToProps)(mapDispatchToProps)(Notifications)
只要您的redux状态更新,它就会重新启动您的组件。connect来自react redux,这与您所说的相同,请在repo中尝试您的方法,我保证您不会成功。