Nice introduction to using TS with React! A few points worth mentioning about React.FC:
It also handles the return type from the component, so JSX.Element return type declaration is redundant.
It types children implicitly, so for example if you have a component that doesn't use children prop but that prop is passed in anyways, no errors will be raised. There's a temporary type - VoidFunctionComponen or VFC, introduced for this reason, which does not take children prop.
In general, I find this cheatsheet really helpful for working with TS in React.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice introduction to using TS with React! A few points worth mentioning about
React.FC
:JSX.Element
return type declaration is redundant.children
implicitly, so for example if you have a component that doesn't usechildren
prop but that prop is passed in anyways, no errors will be raised. There's a temporary type - VoidFunctionComponen orVFC
, introduced for this reason, which does not takechildren
prop.In general, I find this cheatsheet really helpful for working with TS in React.