Replies: 4 comments
-
I agree with this change, looks like 600+ files would need to change. 370+ would be in packages/payload. |
Beta Was this translation helpful? Give feedback.
-
I'm into it too, would be a good PR for someone to make. Gonna convert to discussion and add this to the roadmap |
Beta Was this translation helpful? Give feedback.
-
I have made changes to this only for the tests folder(#7528). This is my first contribution to the codebase. remaining folders to remove React.RC I used this command to refactor the code. npx jscodeshift -- -t https://raw.githubusercontent.com/gndelia/codemod-replace-react-fc-typescript/main/dist/index.js --extensions=tsx --verbose=2 test\fields-relationship |
Beta Was this translation helpful? Give feedback.
-
https://www.totaltypescript.com/you-can-stop-hating-react-fc
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Payload source code, examples and documentation use React.FC (and/or friends: React.FunctionComponent, React.FunctionalComponent)
Instead of writing:
just write:
React and TypeScript perfectly type this for years now.
There is a wide consensus that React.FC (and friends) is obsolete and “dangerous”:
Here a codemod to remove React.FC: https://github.com/gndelia/codemod-replace-react-fc-typescript
You can also add an ESLint rule to ban React.FC: https://stackoverflow.com/a/76818791
Beta Was this translation helpful? Give feedback.
All reactions