Skip to content

fix: remove VFC type usage #2290

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

faergeek
Copy link

It's deprecated in @types/react@^18 (current dev dependency) and completely removed in @types/react@^19, causing type errors.

Description

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Examples update

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

Copy link

vercel bot commented Jul 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
js-lingui ✅ Ready (Inspect) Visit Preview Jul 26, 2025 4:18am

@faergeek faergeek marked this pull request as ready for review July 21, 2025 02:58
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.81%. Comparing base (6bb8983) to head (0428616).
⚠️ Report is 203 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2290      +/-   ##
==========================================
- Coverage   77.05%   76.81%   -0.24%     
==========================================
  Files          84       89       +5     
  Lines        2157     2497     +340     
  Branches      555      650      +95     
==========================================
+ Hits         1662     1918     +256     
- Misses        382      463      +81     
- Partials      113      116       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@vonovak vonovak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think react.FC accepts children which may not be what we want here.

@faergeek
Copy link
Author

@vonovak that was the case up to v17, not the case anymore neither in v18 nor v19

@faergeek
Copy link
Author

Based on peerDependencies 16 and 17 are still supported I guess?

So if having children allowed is a concern, does it make sense to inline FC type without adding children to props then?

@faergeek
Copy link
Author

I've inlined VFC type instead of replacing it with FC.

@yslpn
Copy link
Contributor

yslpn commented Jul 25, 2025

Let's remove FC completely. This type is often considered as a bad practice, more details here

https://github.com/gndelia/codemod-replace-react-fc-typescript?tab=readme-ov-file#man_teacher-motivation

and here

facebook/create-react-app#8177

@faergeek
Copy link
Author

faergeek commented Jul 26, 2025

Replaced both FC and VFC with just a plain function type.

VFC is deprecated in `@types/react@^18` (current dev dependency) and
completely removed in `@types/react@^19`, causing type errors.

FC is unnecessary.
See facebook/create-react-app#8177
@faergeek
Copy link
Author

@yslpn @vonovak is there anything else that should be done before merging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants