[Docs] Fix custom field uses defaultProps for labels - #11367
Merged
fzaninotto merged 2 commits intoSep 10, 2026
Merged
Conversation
fzaninotto
requested changes
Sep 9, 2026
| **Tip**: Always check the `record` is defined before inspecting its properties, as react-admin may display the Show view *before* fetching the record from the data provider. So the first time it renders the show view for a resource, the `record` is `undefined`. | ||
|
|
||
| You can now use this field like any other react-admin field: | ||
| You can now use this field like any other react-admin field. Pass the `label` explicitly so the parent layout can read it from the field's props. A default parameter inside `FullNameField` would not be visible to the parent layout, and React 19 no longer supports `defaultProps` for function components: |
Member
There was a problem hiding this comment.
no need for the last sentence: "A default parameter..."
Contributor
Author
|
Thanks @fzaninotto! Removed the last sentence as suggested. |
fzaninotto
approved these changes
Sep 10, 2026
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The custom field example recommends function-component
defaultProps, which React 19 no longer supports. Replacing it with a default function parameter would not expose the label to the parent layout.Closes #10684.
Solution
Pass
label="Name"explicitly when usingFullNameFieldand explain why the label belongs on the element. The existing Datagrid example and sorting source remain intact.How To Test
Reviewed the example against
DatagridHeaderCellandLabeled, which read the label from the child element's props.git diff --checkpasses. Documentation build and browser rendering were not run.Additional Checks
masterfor a documentation fix