From fcb935b101720225aa9682ddada266d0127b7776 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 19 Aug 2017 12:10:46 +0800 Subject: [PATCH] improve form doc --- components/form/index.en-US.md | 6 +++--- components/form/index.zh-CN.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/form/index.en-US.md b/components/form/index.en-US.md index 92a1a5a482..a6cb488753 100644 --- a/components/form/index.en-US.md +++ b/components/form/index.en-US.md @@ -59,7 +59,7 @@ The following `options` are available: | Property | Description | Type | |-----------|------------------------------------------|------------| | onFieldsChange | Specify a function that will be called when the value a `Form.Item` gets changed. Usage example: saving the field's value to Redux store. | Function(props, fields) | -| mapPropsToFields | Convert props to corresponding field value. Usage example: reading the values from Redux store. | Function(props): Object{ fieldName: Object{ value } } | +| mapPropsToFields | Convert props to field value. Usage example: reading the values from Redux store. | Function(props): Object{ fieldName: Object{ value } } | | onValuesChange | A handler while value of any field is changed | (props, values) => void | If the form has been decorated by `Form.create` then it has `this.props.form` property. `this.props.form` provides some APIs as follows: @@ -87,9 +87,9 @@ If the form has been decorated by `Form.create` then it has `this.props.form` pr After wrapped by `getFieldDecorator`, `value`(or other property defined by `valuePropName`) `onChange`(or other property defined by `trigger`) props will be added to form controls,the flow of form data will be handled by Form which will cause: -1. You don't need to use `onChange` to collect data, but you still can listen to `onChange`(and so on) events. +1. You shouldn't to use `onChange` to collect data, but you still can listen to `onChange`(and so on) events. 2. You can not set value of form control via `value` `defaultValue` prop, and you should set default value with `initialValue` in `getFieldDecorator` instead. -3. You don't need to call `setState` manually, please use `this.props.form.setFieldsValue` to change value programmatically. +3. You shouldn't to call `setState` manually, please use `this.props.form.setFieldsValue` to change value programmatically. #### Special attention diff --git a/components/form/index.zh-CN.md b/components/form/index.zh-CN.md index 52b91c3686..2a4ef53018 100644 --- a/components/form/index.zh-CN.md +++ b/components/form/index.zh-CN.md @@ -61,7 +61,7 @@ CustomizedForm = Form.create({})(CustomizedForm); | 参数 | 说明 | 类型 | |-----------|------------------------------------------|------------| | onFieldsChange | 当 `Form.Item` 子节点的值发生改变时触发,可以把对应的值转存到 Redux store | Function(props, fields) | -| mapPropsToFields | 把 props 转为对应的值,可用于把 Redux store 中的值读出 | Function(props): Object{ fieldName: Object{ value } } | +| mapPropsToFields | 把父组件的属性映射到表单项上(可用于把 Redux store 中的值读出) | Function(props): Object{ fieldName: Object{ value } } | | onValuesChange | 任一表单域的值发生改变时的回调 | (props, values) => void | 经过 `Form.create` 包装的组件将会自带 `this.props.form` 属性,`this.props.form` 提供的 API 如下: @@ -88,9 +88,9 @@ CustomizedForm = Form.create({})(CustomizedForm); 经过 `getFieldDecorator` 包装的控件,表单控件会自动添加 `value`(或 `valuePropName` 指定的其他属性) `onChange`(或 `trigger` 指定的其他属性),数据同步将被 Form 接管,这会导致以下结果: -1. 你不再需要用 `onChange` 来做同步,但还是可以继续监听 `onChange` 等事件。 +1. 你**不再需要也不应该**用 `onChange` 来做同步,但还是可以继续监听 `onChange` 等事件。 2. 你不能用控件的 `value` `defaultValue` 等属性来设置表单域的值,默认值可以用 `getFieldDecorator` 里的 `initialValue`。 -3. 你不需要用 `setState`,可以使用 `this.props.form.setFieldsValue` 来动态改变表单值。 +3. 你不应该用 `setState`,可以使用 `this.props.form.setFieldsValue` 来动态改变表单值。 #### 特别注意