defaultProps recommended for label of custom field
On https://marmelab.com/react-admin/Fields.html#writing-your-own-field-component, it is recommended to use defaultProps for having a default label for a custom field.
As defaultProps for function components do not exist anymore, another way should be recommended.
Other information:
Mention on defaultProps being removed: https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-deprecated-react-apis
Thanks for pointing this. I'm marking it as a documentation issue.
We won't need defaultProps for labellingcustom fields in a data grid with the new DataTable component. We will need to use the same approach for the Show layouts, and then we can stop recommending setting the label on Field components altogether.
I've updated the documentation to remove the defaultProps pattern for custom field components. The changes include:
- Updated the
FullNameFieldexample in Fields.md to use parameter destructuring with source and...propsinstead oflabeland...props - Updated the
ColoredNumberFieldexample in SX.md to: Remove thedefaultPropsassignment Use parameter destructuring withsourceand...propsPass thesourceprop explicitly to the underlying component Should I proceed with a PR ?
As explained in #10699, what you propose doesn't work.
got it! i'll look for another solution.