-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add wrappedComponentRef and deprecate withRef
- Loading branch information
Showing
2 changed files
with
22 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,23 @@ export createForm()(Form); | |
| formOption.mapPropsToFields | Convert value from props to fields. Used for read fields from redux store. | (props): Object | NOOP | | ||
| formOption.withRef(deprecated) | Maintain an ref for wrapped component instance, use `refs.wrappedComponent` to access. | boolean | false | | ||
createForm() will return another function: | ||
### Note: use wrappedComponentRef instead of withRef after [email protected] | ||
```jsx | ||
class Form extends React.Component { ... } | ||
|
||
// deprecated | ||
const EnhancedForm = createForm({ withRef: true })(Form); | ||
<EnhancedForm ref="form" /> | ||
this.refs.form.refs.wrappedComponent // => The instance of Form | ||
|
||
// Recommended | ||
const EnhancedForm = createForm()(Form); | ||
<EnhancedForm wrappedComponentRef={(inst) => this.formRef = inst} /> | ||
this.formRef // => The instance of Form | ||
``` | ||
## createForm() will return another function | ||
### function(WrappedComponent: React.Component): React.Component | ||
|
@@ -272,7 +288,7 @@ Reset specified inputs. Defaults to all. | |
## rc-form/lib/createDOMForm(formOption): Function | ||
createForm enhancement, support props.form.validateFieldsAndScroll | ||
createDOMForm enhancement, support props.form.validateFieldsAndScroll | ||
### props.form.validateFieldsAndScroll([fieldNames: String[]], [options: Object], callback: Function(errors, values)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters