Skip to content

Commit

Permalink
docs: faq about modal. close #35177
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Apr 22, 2022
1 parent f8e7cba commit eb70223
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/modal/index.en-US.md
Expand Up @@ -142,6 +142,10 @@ return <div>{contextHolder}</div>;

## 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.
Expand Down
4 changes: 4 additions & 0 deletions components/modal/index.zh-CN.md
Expand Up @@ -145,6 +145,10 @@ return <div>{contextHolder}</div>;

## FAQ

### 为什么 Modal 关闭时,内容不会更新?

Modal 在关闭时会将内容进行 memo 从而避免关闭过程中的内容跳跃。也因此如果你在配合使用 Form 有关闭时重置 `initialValues` 的操作,请通过在 effect 中调用 `resetFields` 来重置。

### 为什么 Modal 方法不能获取 context、redux、的内容和 ConfigProvider `locale/prefixCls` 配置?

直接调用 Modal 方法,antd 会通过 `ReactDOM.render` 动态创建新的 React 实体。其 context 与当前代码所在 context 并不相同,因而无法获取 context 信息。
Expand Down

0 comments on commit eb70223

Please sign in to comment.