I got an error when I'm trying to write a generic arrow function (see code below) :
interface AutocompleteModalProps<T> {
isVisible: boolean;
searchMethod: (value: string) => T;
renderItem: (item: T) => ReactNode;
children: ReactNode;
}
// Error on the 'T' => "Cannot find name 'T'"
const AutocompleteModal: React.FC<AutocompleteModalProps<T>> = ({
isVisible,
children,
renderItem,
searchMethod,
}) => {
...
};
The "function" way is working, but I have to transform it to an arrow function...
function OldWay<T>({
isVisible,
searchMethod,
renderItem,
children,
}: AutocompleteModalProps<T>) {