1

I have a React component with some generic properties and would like to type them using a generic type T. But I can't figure out where to put the T declaration.

Here's my component signature:

interface MyComponentProps<T> {
  items: T
}

// ------------------------------------------v cannot find name T
const MyComponent: React.FC<MyComponentProps<T>> = ({
  items
}) => {
  // ...
}

Where can I put <T> to satisfy the generic type declaration?

Thanks!

mottosson
  • 3,283
  • 4
  • 35
  • 73
  • [This](https://stackoverflow.com/questions/58656026/what-is-the-difference-between-react-fc-and-jsx-element) will also probably be useful. Basically: There's really no good reason to use `React.FC` at all. :-) – T.J. Crowder Nov 15 '22 at 11:45
  • This does not answer the generic part of the question. – Zlatko Nov 15 '22 at 11:47

0 Answers0