react-activation
react-activation copied to clipboard
组件数据量大,导致缓存失效。
使用 react-activation 来对 antd 中的 tabs 组件进行缓存,当 TabPane 中组件内容过多时,缓存会失效。当 TabPane 中组件内容不多时,缓存是正常的,并且滚动条位置也能保存下来。
<AliveScope>
<Tabs
hideAdd
onChange={onChange}
activeKey={activeKey}
type="editable-card"
onEdit={handEdit}
>
{panes.length > 0 && panes.map((pane: any) => (
<TabPane tab={pane.title} key={pane.key}>
<KeepAlive>
{pane.content}
</KeepAlive>
</TabPane>
))}
</Tabs>
...
</AliveScope>
如果可以的话,希望提供一个在线示例,最近比较忙