You need to rewrite your Test
component in this way
const Test= <T,>(props:TestProps<T>) => (
<span>Some component logic</span>
);
Can you show the same with React.FC<TestProps>?
It is impossible to do withFC
.
This is FC
implementation:
interface FunctionComponent<P = {}> {
(props: PropsWithChildren<P>, context?: any): ReactElement<any, any> | null;
// ... other static properties
}
As you might have noticed, FC
is a function type, not type of props.
UPDATE
You can create higher order function, but I’m not sure if it worth it
const WithGeneric = <T,>(): React.FC<TestProps<T>> =>
(props: TestProps<T>) => (
<span>Some component logic</span>
);
const Test = WithGeneric<Obj>()