【问题标题】:Prevent antd component from rerender防止antd组件重新渲染
【发布时间】:2021-12-05 07:37:31
【问题描述】:

我有一个由 react-query 包装的 antd collapse 组件,我在查询中启用了refetchInterval,所以问题是 antd Collapse 组件在打开后自动恢复到其初始状态(关闭)我给RefetchInterval 的时间已经设置好了,有没有办法防止这种行为?

【问题讨论】:

标签: reactjs antd react-query


【解决方案1】:

您可以在Collapse组件的defaultActiveKey中传递Collapse.Panel的key。

<Collapse  defaultActiveKey={['1']}>
    <Collapse.Panel header="panel1" key="1">
        //some components
    </Collapse.Panel>
</Collapse>
   

您可以使用状态并将其传递给 CollapseactiveKey 道具。

欲了解更多信息:https://ant.design/components/collapse/#API

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-07
    • 2020-03-09
    • 2021-05-24
    • 2021-02-14
    • 1970-01-01
    • 1970-01-01
    • 2020-03-27
    • 2018-12-02
    相关资源
    最近更新 更多