From eb70223bdb2c2619067bcb47ba424ddef397c6c4 Mon Sep 17 00:00:00 2001 From: zombiej Date: Fri, 22 Apr 2022 19:30:44 +0800 Subject: [PATCH] docs: faq about modal. close #35177 --- components/modal/index.en-US.md | 4 ++++ components/modal/index.zh-CN.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/components/modal/index.en-US.md b/components/modal/index.en-US.md index 2479edbc99..85d8a8caf6 100644 --- a/components/modal/index.en-US.md +++ b/components/modal/index.en-US.md @@ -142,6 +142,10 @@ return
{contextHolder}
; ## FAQ +### Why content not update when Modal closed? + +Modal will use memo to avoid content jumping when closed. Also, if you use Form in Modal, you can reset `initialValues` by calling `resetFields` in effect. + ### Why I can not access context, redux, ConfigProvider `locale/prefixCls` in Modal.xxx? antd will dynamic create React instance by `ReactDOM.render` when call Modal methods. Whose context is different with origin code located context. diff --git a/components/modal/index.zh-CN.md b/components/modal/index.zh-CN.md index 7074a69970..0308d2aa13 100644 --- a/components/modal/index.zh-CN.md +++ b/components/modal/index.zh-CN.md @@ -145,6 +145,10 @@ return
{contextHolder}
; ## FAQ +### 为什么 Modal 关闭时,内容不会更新? + +Modal 在关闭时会将内容进行 memo 从而避免关闭过程中的内容跳跃。也因此如果你在配合使用 Form 有关闭时重置 `initialValues` 的操作,请通过在 effect 中调用 `resetFields` 来重置。 + ### 为什么 Modal 方法不能获取 context、redux、的内容和 ConfigProvider `locale/prefixCls` 配置? 直接调用 Modal 方法,antd 会通过 `ReactDOM.render` 动态创建新的 React 实体。其 context 与当前代码所在 context 并不相同,因而无法获取 context 信息。