Skip to content

Commit 54e90c0

Browse files
eugene-stativkaerikras
authored andcommitted
Fix Flow typings for UseFieldConfig and FieldProps (#503)
There was a mismatch between the source code and Flow typings which led to the following error: ```js <Field name={name} component={SomeCustomInputComponent} /* ^^^ Flow error here: Cannot create Field element because in property component: • Either function [1] is incompatible with string literal input [2]. • Or function [1] is incompatible with string literal select [3]. • Or function [1] is incompatible with string literal textarea [4]. */ ```
1 parent fdb6668 commit 54e90c0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/types.js.flow

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export type UseFieldConfig = {
7575
afterSubmit?: () => void,
7676
allowNull?: boolean,
7777
beforeSubmit?: () => void | false,
78-
component?: SupportedInputs,
78+
children?: $PropertyType<RenderableProps<*>, 'children'>,
79+
component?: $PropertyType<RenderableProps<*>, 'component'>,
7980
defaultValue?: any,
8081
format?: (value: any, name: string) => any,
8182
formatOnBlur?: boolean,
@@ -92,9 +93,7 @@ export type UseFieldConfig = {
9293

9394
export type FieldProps = UseFieldConfig & {
9495
name: string
95-
} & RenderableProps<FieldRenderProps> & {
96-
component?: React.ComponentType<*> | SupportedInputs
97-
}
96+
} & RenderableProps<FieldRenderProps>
9897

9998
export type UseFormStateParams = {
10099
onChange?: (formState: FormState) => void,

0 commit comments

Comments
 (0)