Skip to content

Commit d5517bd

Browse files
committed
Add ComponentProps type
1 parent 944796d commit d5517bd

File tree

2 files changed

+370
-382
lines changed

2 files changed

+370
-382
lines changed

src/Form.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ import {
1818
FormItemChildrenProps,
1919
} from "./types";
2020

21+
export type ComponentProps = {
22+
style: React.CSSProperties;
23+
className: string;
24+
onSubmit: (e: React.FormEvent) => void;
25+
};
26+
2127
export interface IFormProps {
2228
prefixCls: string;
2329
className: string;
@@ -97,11 +103,17 @@ export class Form extends React.Component<Partial<IFormProps>, IFormState> {
97103
fields: FormItem[] = [];
98104
_validateCb: ValueChangeCallback[] = [];
99105

100-
state: IFormState = {
101-
formError: {},
102-
validatingFields: {},
103-
formValue: this.props.defaultFormValue || {},
104-
};
106+
state: IFormState;
107+
108+
constructor(props: IFormProps, context?: any) {
109+
super(props, context);
110+
111+
this.state = {
112+
formError: {},
113+
validatingFields: {},
114+
formValue: props.defaultFormValue || {},
115+
};
116+
}
105117

106118
addField(field: FormItem) {
107119
this.fields.push(field);

0 commit comments

Comments
 (0)