Skip to content

Commit 2f25093

Browse files
authored
chore: fix ts def (#408)
* chore: fix ts def * chore: bump typescript
1 parent 92d812b commit 2f25093

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
"@types/enzyme": "^3.10.5",
5858
"@types/jest": "^26.0.20",
5959
"@types/lodash": "^4.14.135",
60-
"@types/react": "^16.8.19",
61-
"@types/react-dom": "^16.8.4",
60+
"@types/react": "^18.0.0",
61+
"@types/react-dom": "^18.0.0",
6262
"@umijs/fabric": "^2.5.2",
6363
"@umijs/test": "^3.2.27",
6464
"dumi": "^1.1.0",
@@ -78,6 +78,6 @@
7878
"react-redux": "^4.4.10",
7979
"react-router": "^3.0.0",
8080
"redux": "^3.7.2",
81-
"typescript": "^3.5.2"
81+
"typescript": "^4.6.3"
8282
}
8383
}

src/Form.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { FormContextProps } from './FormContext';
1313
import FormContext from './FormContext';
1414
import { isSimilar } from './utils/valueUtil';
1515

16-
type BaseFormProps = Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit'>;
16+
type BaseFormProps = Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit' | 'children'>;
1717

1818
type RenderProps = (values: Store, form: FormInstance) => JSX.Element | React.ReactNode;
1919

@@ -117,11 +117,13 @@ const Form: React.ForwardRefRenderFunction<FormInstance, FormProps> = (
117117
);
118118

119119
// Prepare children by `children` type
120-
let childrenNode = children;
120+
let childrenNode: React.ReactNode;
121121
const childrenRenderProps = typeof children === 'function';
122122
if (childrenRenderProps) {
123123
const values = formInstance.getFieldsValue(true);
124124
childrenNode = (children as RenderProps)(values, formInstance);
125+
} else {
126+
childrenNode = children;
125127
}
126128

127129
// Not use subscribe when using render props

src/FormContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface FormProviderProps {
1717
validateMessages?: ValidateMessages;
1818
onFormChange?: (name: string, info: FormChangeInfo) => void;
1919
onFormFinish?: (name: string, info: FormFinishInfo) => void;
20+
children?: React.ReactNode;
2021
}
2122

2223
export interface FormContextProps extends FormProviderProps {

0 commit comments

Comments
 (0)