You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some differences from the "normal function" version:
177
177
178
-
- It provides typechecking and autocomplete for static properties like `displayName`, `propTypes`, and `defaultProps` - **However**, there are currently known issues using `defaultProps` with `React.FunctionComponent`. See [this issue for details](https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/issues/87) - scroll down to our `defaultProps` section for typing recommendations there.
178
+
-`React.FunctionComponent` is explicit about the return type, while the normal function version is implicit (or else needs additional annotation).
179
+
180
+
- It provides typechecking and autocomplete for static properties like `displayName`, `propTypes`, and `defaultProps`.
181
+
- Note that there are some known issues using `defaultProps` with `React.FunctionComponent`. See [this issue for details](https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/issues/87). We maintain a separate `defaultProps` section you can also look up.
179
182
180
183
- It provides an implicit definition of `children` (see below) - however there are some issues with the implicit `children` type (e.g. [DefinitelyTyped#33006](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/33006)), and it might considered better style to be explicit about components that consume `children`, anyway.
-_In the future_, it may automatically mark props as `readonly`, though that's a moot point if the props object is destructured in the parameter list.
190
193
191
-
-`React.FunctionComponent` is explicit about the return type, while the normal function version is implicit (or else needs additional annotation).
192
-
193
-
In most cases it makes very little difference which syntax is used, but the `React.FC` syntax is slightly more verbose without providing clear advantage, so precedence was given to the "normal function" syntax.
194
+
In most cases it makes very little difference which syntax is used, but you may prefer the more explicit nature of `React.FunctionComponent`.
0 commit comments