docs: Update Form FAQ

This commit is contained in:
zombiej 2020-08-25 11:27:01 +08:00
parent 902f5617db
commit 04d7a81ff7
2 changed files with 8 additions and 0 deletions

View File

@ -338,6 +338,10 @@ Before Modal opens, children elements do not exist in the view. You can set `for
Components inside Form.Item with name property will turn into controlled mode, which makes `defaultValue` not work anymore. Please try `initialValues` of Form to set default value.
### Why can not call `ref` of From at first time?
`ref` only receives the mounted instance. please ref React official doc: https://reactjs.org/docs/refs-and-the-dom.html#accessing-refs
### Why `resetFields` will re-mount component?
`resetFields` will re-mount component under Field to clean up customize component side effects (like async data, cached state, etc.). It's by design.

View File

@ -340,6 +340,10 @@ validator(rule, value, callback) => {
当你为 Form.Item 设置 `name` 属性后,子组件会转为受控模式。因而 `defaultValue` 不会生效。你需要在 Form 上通过 `initialValues` 设置默认值。
### 为什么第一次调用 `ref` 的 From 为空?
`ref` 仅在节点被加载时才会被赋值,请参考 React 官方文档https://reactjs.org/docs/refs-and-the-dom.html#accessing-refs
### 为什么 `resetFields` 会重新 mount 组件?
`resetFields` 会重置整个 Field因而其子组件也会重新 mount 从而消除自定义组件可能存在的副作用(例如异步数据、状态等等)。