QuizNot attempted
Generic components in .tsx
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- The parser reads
<T>as a JSX tag; write<T,>or<T extends unknown>
- In
.tsx,<T>at the start of an arrow function parses as an opening JSX tag <T,>or<T extends unknown>disambiguates.- Not 'arrows can't be generic': they can in
.tsfiles and with the fix. - Not 'components can't take generic props': generic components are common (
List<T>). - Not React.FC<T>:
FCcan't express a generic component. - Function declarations don't have the ambiguity.