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.16k stars 113 forks source link

怎么动态设置cacheKey的值? #127

Closed SKNlEI closed 3 years ago

SKNlEI commented 3 years ago

比如我同一个路由,但是路由上不同的查询参数 /test?id=10和/test?id=50 我想两个都缓存的话应该怎么处理呀?请教大佬

CJY0208 commented 3 years ago

这样子试试,cacheKey 可以是函数,函数参数是 CacheRoute 内部 CacheComponent 获得的 props <CacheRoute cacheKey={(props) => test?${props.location.search}} />

SKNlEI commented 3 years ago

感谢,已经使用这个方法实现了,感谢