I have a function that wraps a React component with <IntlContextProvider> component. I want to define the GenericFunctionType but I have no ideia what shoulb be.
const wrapIntl: GenericFunctionType = (ComponentToWrap) => {
class Wrapper extends React.PureComponent {
render() {
return (
<IntlContextProvider>
<ComponentToWrap {...this.props}/>
</IntlContextProvider>
);
}
}
return Wrapper;
}
This function wrapIntl will be used like this:
export const TranslateText = wrapIntl(({text}: {text: string}) =>
<>
{React.useContext(IntlContext).translate(text)}
</>
)
I have this now:
interface GenericFunctionType {
<T>(ComponentToWrap: React.ReactNode): T
}
But it has this errors:
TS2322: Type '(ComponentToWrap: ReactNode) => typeof Wrapper' is not assignable to type 'WrapIntlFunctionType'. Type 'typeof Wrapper' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'typeof Wrapper'.
TS2604: JSX element type 'ComponentToWrap' does not have any construct or call signatures.