Redux状态为未保存的更改保留标志,如果设置了此标志,我想在导航时单击用户(单击链接)。我正在使用react-router-component。我没有在文档中找到如何做到这一点。
答案 0 :(得分:5)
任何人在2018年到达这个帖子并使用反应路由器4+,我建议阅读reacttraining example
TL; DR使用顶部的ProxyPass "/app_2" "http://IP2"
ProxyPassReverse "/site2" "http://IP2"
ProxyPass "/app_2_api" "http://IP2/api"
ProxyPassReverse "/site2_api" "http://IP2/api"
组件
if len(self.train_queue[0]) < MIN_BATCH:
return
答案 1 :(得分:1)
您应该只需创建自己的链接组件(继承自Router.NavigatableMixin
,例如https://github.com/STRML/react-router-component/issues/105#issuecomment-63874805和此处http://strml.viewdocs.io/react-router-component/recipes/custom-link/)。
然后,您只需通过提示用户是否要离开,如果“是”,您只需继续使用this.navigate(...)
(来自您的组件,继承自Navigatable),就可以处理该组件上的点击事件。