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

React.FC vs React.FunctionComponent #190

Closed
ElForastero opened this issue Feb 27, 2020 · 7 comments
Closed

React.FC vs React.FunctionComponent #190

ElForastero opened this issue Feb 27, 2020 · 7 comments
Assignees
Labels
BASIC Basic Cheatsheet

Comments

@ElForastero
Copy link

ElForastero commented Feb 27, 2020

What cheatsheet is this about? (if applicable)

Basic cheatsheet

What's your issue or idea?

Last year some recommendations on using FunctionComponent instead of FC were added to this cheatsheet in #104.

But seems like things have changed since then and now these two types are identical. 🤔

image

@ElForastero ElForastero added the BASIC Basic Cheatsheet label Feb 27, 2020
@eps1lon
Copy link
Member

eps1lon commented Feb 27, 2020

Since this cheatsheet is mostly aimed at beginners I would generally avoid abbreviations.

But that doesn't mean we should recommend one over the other. I think using FunctionComponent and mentioning once that this is also available as FC is a good compromise.

@swyxio
Copy link
Collaborator

swyxio commented Mar 25, 2020

ah, i didnt know this recommendation had changed. it actually came from @ferdaber. yeah we should tell people both exist. thanks will address.

@swyxio swyxio closed this as completed in af5fcd0 Mar 25, 2020
@ferdaber
Copy link
Collaborator

Ah yeah my bad. I don't even recommend using either nowadays now that TypeScript supports namespace augmentation to functions.

@swyxio
Copy link
Collaborator

swyxio commented Mar 25, 2020

no worries man. glad to see you're doing ok :)

@ElForastero
Copy link
Author

@ferdaber Hi. I'm curious about "namespace augmentation to functions". Can you share some details?) Can't google it. 🤔

@ferdaber
Copy link
Collaborator

This change is what documents it, it allows you to assign properties of functions and arrow functions after they're declared and it updates the type of the function. This achieves the same functionality that you would get if you declare a function and a namespace with the same name. https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#properties-declarations-on-functions

@swyxio
Copy link
Collaborator

swyxio commented Mar 30, 2020

yea i believe in general namespaces are on their way out in TS. at least for users, i believe its still relevant in library code.

bernssolg added a commit to bernssolg/My-React-Sample that referenced this issue Feb 28, 2022
erinodev added a commit to erinodev/My-React-project that referenced this issue Feb 28, 2022
kevindavies8 added a commit to kevindavies8/react-full-stack-developer that referenced this issue Aug 24, 2022
johnfrench3 pushed a commit to johnfrench3/react-Fronted-developer that referenced this issue Sep 7, 2022
ericbrown2716 added a commit to ericbrown2716/react-stack-build-website that referenced this issue Sep 29, 2022
peterjohnson4987 added a commit to peterjohnson4987/full-stack-developer-react that referenced this issue Oct 3, 2022
renawolford6 pushed a commit to renawolford6/react-husky-website that referenced this issue Oct 6, 2022
renawolford6 added a commit to renawolford6/react-dev-build-doc- that referenced this issue Nov 10, 2022
coopfeathy added a commit to coopfeathy/cheatsheet that referenced this issue Dec 4, 2022
dreamcoder75 added a commit to dreamcoder75/react-sample that referenced this issue Jan 15, 2023
holyblock pushed a commit to holyblock/chart that referenced this issue Feb 27, 2023
AIDevMonster added a commit to AIDevMonster/Awesome-React that referenced this issue Jun 21, 2023
whiteghostDev added a commit to whiteghostDev/Awesome-React that referenced this issue Aug 6, 2023
cedev935 added a commit to cedev935/React-TypeScript that referenced this issue Sep 11, 2023
aleksandaralek added a commit to aleksandaralek/typescript-react-cheatsheet that referenced this issue Oct 24, 2023
xbucks pushed a commit to xbucks/react-cheatsheets that referenced this issue Oct 24, 2023
KonohaBrain125 pushed a commit to KonohaBrain125/React-Typescript that referenced this issue Oct 26, 2023
TOP-10-DEV added a commit to TOP-10-DEV/typescript-cheatsheets-react that referenced this issue Dec 8, 2023
secretsuperstar1109 added a commit to secretsuperstar1109/react-typescript-cheatsheets that referenced this issue Dec 9, 2023
EugeneYoona added a commit to EugeneYoona/React_full_src that referenced this issue Apr 10, 2024
fairskyDev0201 added a commit to fairskyDev0201/typescript-cheatsheet that referenced this issue Apr 17, 2024
solutionGuru0129 added a commit to solutionGuru0129/react that referenced this issue May 27, 2024
alisenola added a commit to alisenola/react-cheatsheets that referenced this issue May 29, 2024
marceloaguilera94 pushed a commit to marceloaguilera94/react that referenced this issue Jun 5, 2024
miracle-soft-expert added a commit to miracle-soft-expert/React-TypeScript that referenced this issue Oct 15, 2024
roman-sherman added a commit to roman-sherman/react-test that referenced this issue Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BASIC Basic Cheatsheet
Projects
None yet
Development

No branches or pull requests

4 participants