npm install react-activation

import { KeepAlive, AliveScope } from 'react-activation';

使用 在最外层使用 AliveScope把元素包裹 在想缓存的组件中使用 KeepAlive包裹 如果有多个需要缓存的 需要指定name

<AliveScope>

{

show?<div></div>:<KeepAlive name="div1"><div></div</KeepAlive>>

}

</AliveScope>

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐