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

Review with React 18 types in mind #495

Open
1 of 4 tasks
eps1lon opened this issue Apr 11, 2022 · 13 comments · Fixed by #633
Open
1 of 4 tasks

Review with React 18 types in mind #495

eps1lon opened this issue Apr 11, 2022 · 13 comments · Fixed by #633
Labels
BASIC Basic Cheatsheet wontfix This will not be worked on

Comments

@eps1lon
Copy link
Member

eps1lon commented Apr 11, 2022

We had some type-related breaking changes with React 18 that were supposed to fix long standing issues. If we describe these issues here, reference React 18 types that fix those issues.

@eps1lon eps1lon added the BASIC Basic Cheatsheet label Apr 11, 2022
@LukasKalbertodt
Copy link

In particular, the guide also mentions that React.FC is discouraged. The main reason against it seems to be the implicit children. But this has changed with 18.0.0, so I wonder if FC is still discouraged. The remaining reasons against it seem rather minor?

@filiptammergard
Copy link
Collaborator

I created #496 before I saw this. Let me know if you want to handle it in another way or feel free to just close the PR.

@filiptammergard
Copy link
Collaborator

The other place that came to mind was the section "Small React.ReactNode edge case" here: https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/basic_type_example/#useful-react-prop-type-examples. Created a PR for that as well: #497

But I'm not sure how you would like to convey this, so just let me know if you have other ideas.

@filiptammergard
Copy link
Collaborator

In particular, the guide also mentions that React.FC is discouraged. The main reason against it seems to be the implicit children. But this has changed with 18.0.0, so I wonder if FC is still discouraged. The remaining reasons against it seem rather minor?

The main reason behind React.FC being discouraged might be gone, but there are still some smaller problems remaining and no real benefits with using it. Even though React.FC might not need to be discouraged as much, I still wouldn't encourage using it.

@swyxio
Copy link
Collaborator

swyxio commented Apr 19, 2022

hey @filiptammergard really appreciate the comments! I just invited you to help maintain this repo :)

i've personally never used React.FC so never engaged in that debate but let me know if the consensus shifts :) all i care about on that topic is just to give a concise summary of the tradeoffs if you choose ot use it

@stale
Copy link

stale bot commented Aug 10, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the wontfix This will not be worked on label Aug 10, 2022
@eps1lon eps1lon removed the wontfix This will not be worked on label Aug 11, 2022
@stale
Copy link

stale bot commented Oct 14, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the wontfix This will not be worked on label Oct 14, 2022
@filiptammergard filiptammergard removed the wontfix This will not be worked on label Oct 14, 2022
@stale
Copy link

stale bot commented Dec 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the wontfix This will not be worked on label Dec 16, 2022
@filiptammergard filiptammergard removed the wontfix This will not be worked on label Dec 16, 2022
@stale
Copy link

stale bot commented Mar 19, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the wontfix This will not be worked on label Mar 19, 2023
@filiptammergard filiptammergard removed the wontfix This will not be worked on label Mar 20, 2023
@stale
Copy link

stale bot commented May 20, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the wontfix This will not be worked on label May 20, 2023
@filiptammergard filiptammergard removed the wontfix This will not be worked on label May 20, 2023
@jonenst
Copy link

jonenst commented Jul 20, 2023

From what I understand the last remaining pitfalls with React.FC were fixed with DefinitelyTyped/DefinitelyTyped@443451c released in https://unpkg.com/@types/[email protected]/index.d.ts ?

I'm talking about these two:

Minor Pitfalls

These patterns are not supported:
  Conditional rendering
  Array.fill

@filiptammergard
Copy link
Collaborator

@jonenst Fixed in #633!

Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the wontfix This will not be worked on label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BASIC Basic Cheatsheet wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants