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

pull/3024/head
Benjy Cui 9 years ago committed by GitHub
parent cbfc181fa4
commit 37e8474714

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

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

Loading…
Cancel
Save