CJY0208 / react-router-cache-route

Route with cache for react-router V5 like <keep-alive /> in Vue
https://www.npmjs.com/package/react-router-cache-route
MIT License
1.14k stars 110 forks source link

请问下作者如何处理跳转路径完全相同,但是state不同的情况 #154

Closed yongchaozeng closed 1 year ago

yongchaozeng commented 1 year ago

https://codesandbox.io/s/cache-route-demo-forked-yqkzv3?file=/src/App.js 在这个demo地址,我把第49行 search: ?id=${idx}, 注释掉,然后每次进入页面,虽然都能拿到最新的state,但是Counter组件却缓存了 实际公司项目中,很多传参是通过state,而path地址完全一致,请问有办法解决这个吗

yongchaozeng commented 1 year ago

犯蠢了,想了想可以通过path相同,清空前一个来解决

CJY0208 commented 1 year ago

也可以给 Couter 加 key 触发强制重新渲染

image