CJY0208 / react-activation

Hack <KeepAlive /> for React
https://www.npmjs.com/package/react-activation
MIT License
1.78k stars 140 forks source link

组件数据量大,导致缓存失效。 #294

Open Huhui-coder opened 10 months ago

Huhui-coder commented 10 months ago

使用 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>
CJY0208 commented 10 months ago

如果可以的话,希望提供一个在线示例,最近比较忙