In a TSX file, a generic component can be defined:
const MyComponent = <A,>() => <p>my component</p>
Note the ,
after A
.
Now if I want A
to be string
by default, one would naturally assume that the above should be written:
const MyComponent = <A=string,>() => <p>my component</p>
Except this does not work.
What am I missing?
<A,>
(or e.g.<A extends any>
) rather than<A>
resolves a parsing ambiguity, but the=string
apparently looks enough like a prop to confuse it again. – Plasma