fix: withRef should work, close: #2843 (#2992)

This commit is contained in:
Benjy Cui 2016-09-14 10:25:44 +08:00 committed by GitHub
parent cbfc181fa4
commit 37e8474714
2 changed files with 8 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import { FIELD_META_PROP } from './constants';
export interface FormCreateOption {
onFieldsChange?: (props: any, fields: Array<any>) => void;
mapPropsToFields?: (props: any) => void;
withRef?: boolean;
}
export interface FormProps {
@ -125,7 +126,12 @@ export default class Form extends React.Component<FormProps, any> {
return getFieldProps(name, option);
}
this.props.form.getFieldProps = deprecatedGetFieldProps;
return <Component {...this.props} />;
const withRef: any = {};
if (options && options.withRef) {
withRef.ref = 'formWrappedComponent';
}
return <Component {...this.props} {...withRef} />;
},
}));
};

View File

@ -2,7 +2,7 @@
order: 14
title:
zh-CN: 与 Modal 配合使用
en-US: To use with modal
en-US: With Modal
---
## zh-CN