DEV Community

Discussion on: Passing props in React using Typescript

clarity89 profile image
Alex K.

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.