fix: wrappedComponentRef should work, close: #6545

This commit is contained in:
Benjy Cui 2017-08-09 10:27:34 +08:00
parent 3001ca4114
commit 87bfe2df87

View File

@ -139,7 +139,7 @@ export default class Form extends React.Component<FormProps, any> {
static Item = FormItem;
static create = function<TOwnProps>(options?: FormCreateOption): ComponentDecorator<TOwnProps> {
static create = function<TOwnProps>(options: FormCreateOption = {}): ComponentDecorator<TOwnProps> {
const formWrapper = createDOMForm({
fieldNameProp: 'id',
...options,
@ -174,8 +174,10 @@ export default class Form extends React.Component<FormProps, any> {
this.props.form.getFieldProps = this.deprecatedGetFieldProps;
const withRef: any = {};
if (options && options.withRef) {
if (options.withRef) {
withRef.ref = 'formWrappedComponent';
} else if (this.props.wrappedComponentRef) {
withRef.ref = this.props.wrappedComponentRef;
}
return <Component {...this.props} {...withRef} />;
},