I'm creating a component that takes an arbitrary list of values and a transformer that will render a specific value. The values can be of any type, as the rendering is handler by the transformer, but the compiler is complaining about the generics parameter.
Here is a minimal example:
interface MyListParams<T> {
values: T[];
transformer: (value: T) => JSX.Element
}
export const MyList: React.FunctionComponent<MyListParam<T>> = ({
}) => <>
{values.map(transformer)}
</>
This code gives me the error Cannot find name 'T'. in code React.FunctionComponent<MyListParam<T>>.
I do realize that I have to tell typescript that this function is using generics, but I fail to find the correct place to do so.