I am working on a TypeScript React component whose props also take a generic type, so I declare the React component as
export interface MyCompProps<T> {
items: T[];
labelFunction: (T) => string;
iconFunction: (T) => JSX.Element;
}
export const MyComp: FunctionComponent<MyCompProps<T>> = (props: MyCompProps<T>) => {
// rendering logic goes here
}
Obviously that didn’t do well with TypeScript compiler. What would be the proper syntax to achieve that goal?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…