react-activation
react-activation copied to clipboard
多个路由指向一个文件时候,缓存是失败
这是页面组件,所有路由都指向这个代码
<div key={props?.location?.pathname}> <keepAlive name={props?.location?.pathname}> <p>{props?.location?.pathname}</p> <Applet {...props} portletComponent={PortletComponent} /> </keepAlive> </div>
不确定是否和react-activation有关系,还望大佬,指点一二。
div的key是因为多路由指向一个文件时候需要的
我觉得上面代码应该改成这样
<div > <keepAlive name={props?.location?.pathname}> <p>{props?.location?.pathname}</p> <Applet {...props} portletComponent={PortletComponent} key={props?.location?.pathname}/> </keepAlive> </div>
调试图片:
是有多个keeper的,就是切回路由的时候Applet里面的组件显示不对
但是tab再切回上一个tab的时候,他还是未切换前的数据
还是大佬有其他方案,求指点。。
可以提供简单的用例吗?