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

[RFR] Remove FC usage from Field components #6538

Merged
merged 7 commits into from
Aug 30, 2021

Conversation

WiXSL
Copy link
Contributor

@WiXSL WiXSL commented Aug 27, 2021

No description provided.

@WiXSL WiXSL changed the title [WIP] Remove FC usage from Field components [RFR] Remove FC usage from Field components Aug 28, 2021
Copy link
Contributor

@djhi djhi left a comment

Choose a reason for hiding this comment

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

Thanks!

@djhi djhi added this to the 3.18 milestone Aug 30, 2021
@djhi djhi merged commit 222c66f into marmelab:master Aug 30, 2021
@WiXSL WiXSL deleted the remove-fc-fields branch August 30, 2021 13:00
@fzaninotto
Copy link
Member

I'm afraid we'll have to revert this one. To see why, try to run the demo with make demo in the latest master. The TS compilation fails with a weird

Failed to compile.

~/react-admin/examples/demo/src/visitors/ColoredNumberField.tsx
TypeScript error in ~/react-admin/examples/demo/src/visitors/ColoredNumberField.tsx(15,47):
Property 'defaultProps' does not exist on type 'NamedExoticComponent'. TS2339

   14 | 
   15 | ColoredNumberField.defaultProps = NumberField.defaultProps;
      |                                               ^
   16 | 
   17 | export default ColoredNumberField;
   18 |

The culprit is DefinitelyTyped/React, which types React.memo with this NamedExoticComponent that doesn't support defaultProps.

This bug has been closed without fix: DefinitelyTyped/DefinitelyTyped#36320

So although FC has drawbacks, not using FC for memoized components is worse.

@fzaninotto
Copy link
Member

I'll make a PR to fix it

@WiXSL
Copy link
Contributor Author

WiXSL commented Sep 13, 2021

Thank you!

fzaninotto added a commit that referenced this pull request Sep 13, 2021
ogustavo-pereira pushed a commit to ogustavo-pereira/react-admin that referenced this pull request Nov 23, 2021
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.

None yet

3 participants