Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Vadorequest opened this issue Mar 31, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@Vadorequest
Copy link
Member

See facebook/create-react-app#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
Copy link
Member Author

Vadorequest commented Apr 28, 2021

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

DefinitelyTyped/DefinitelyTyped#34237 (comment)

@Vadorequest Vadorequest self-assigned this Apr 28, 2021
@Vadorequest Vadorequest added the enhancement New feature or request label Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant