[英]While using react-router 5 with redux 7 react-router <Link> is not resetting state after going to new route
[英]react-router Link changing route prior to redux state updates?
我有 2 頁 A 和 B。B 上有一個鏈接,通過react-router
Link
指向 A。
B -> 單擊鏈接到 A -> A
B 在componentWillUnmount
上調度一個 redux 操作,更新一些 state 應該反映在 A 中。但是,盡管 redux 操作在 A 的componentDidMount
之前運行,但當生命周期方法運行時,道具尚未更新。 安裝 A 后有一個額外的重新渲染,反映了新的 redux state,但我想要安裝上的道具。
有什么簡單的方法可以解決這個問題嗎?
經過更多的研究,這似乎是 React 可以選擇何時調用componentWillMount
和componentWillUnmount
的預期,所以這並不是一個正確的假設。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.