UnlyEd / next-right-now

Flexible production-grade boilerplate with Next.js 11, Vercel and TypeScript. Includes multiple opt-in presets using Storybook, Airtable, GraphQL, Analytics, CSS-in-JS, Monitoring, End-to-end testing, Internationalization, CI/CD and SaaS B2B multi single-tenancy (monorepo) support
https://unlyed.github.io/next-right-now/
MIT License
1.26k stars 111 forks source link

Remove usage of `React.FC` (FunctionComponent) as it is now considered as a bad practice #303

Open Vadorequest opened 3 years ago

Vadorequest commented 3 years ago

See https://github.com/facebook/create-react-app/pull/8177

All components use React.FC in NRN, I liked it because it made explicit the component were functional, but it has a few drawbacks.

Planning on changing that for all components.

Vadorequest commented 3 years ago

Alternative: VoidFunctionComponent from React.

Example:

type Props = {
  children: React.ReactElement | string;
  containerStyle?: CSSStyles;
} & Partial<TooltipProps>;

const HelpTooltip: VoidFunctionComponent<Props> = (props): JSX.Element => {
  ...
}

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L549

https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34237#issuecomment-585816352