Formik: The motivation behind using void for component property

Created on 8 Aug 2019  路  4Comments  路  Source: formium/formik

鉂換uestion

Hi, I just recently came across this chunk in formik source code, which is causing type inconsistencies in my app when trying to use component for FieldArray:

export interface SharedRenderProps<T> {
    component?: string | React.ComponentType<T | void>;
    render?: ((props: T) => React.ReactNode);
    children?: ((props: T) => React.ReactNode);
}

Could you please explain why void type is used for component properties here?

stale

Most helpful comment

+1 to question.

It is now literally impossible to use component property in FIeldArray with proper typings and without some unneded typing tricks.

@jaredpalmer it would be great if you could check whether this property's type definition is correct.

All 4 comments

Not sure exactly why off the top of my head.

+1 to question.

It is now literally impossible to use component property in FIeldArray with proper typings and without some unneded typing tricks.

@jaredpalmer it would be great if you could check whether this property's type definition is correct.

+1, seems like the void is a mistake

Yeah, void type makes no sense and forces to use type casting. Maybe it was meant to be undefined? Why would ever received props have void type?

@jaredpalmer do you need help fixing this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pmonty picture pmonty  路  3Comments

Jungwoo-An picture Jungwoo-An  路  3Comments

ancashoria picture ancashoria  路  3Comments

Jucesr picture Jucesr  路  3Comments

sibelius picture sibelius  路  3Comments