From d571100628f14ac6153a044b60589b21446a4e90 Mon Sep 17 00:00:00 2001 From: Jabrail <78273416+jabrailkhalil@users.noreply.github.com> Date: Wed, 9 Sep 2026 00:08:25 +0300 Subject: [PATCH 1/2] docs: pass custom field labels explicitly --- docs/Fields.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/Fields.md b/docs/Fields.md index 2afa76476de..d1f17341883 100644 --- a/docs/Fields.md +++ b/docs/Fields.md @@ -495,13 +495,11 @@ export const FullNameField = (props) => { const record = useRecordContext(props); return record ? {record.firstName} {record.lastName} : null; } - -FullNameField.defaultProps = { label: 'Name' }; ``` **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: ```jsx import { List, Datagrid } from 'react-admin'; @@ -510,7 +508,7 @@ import { FullNameField } from './FullNameField'; export const UserList = () => ( - + ); From 5b4099b357a87825974b45c8b9fc32a0885ecf24 Mon Sep 17 00:00:00 2001 From: jabrailkhalil Date: Wed, 9 Sep 2026 19:04:16 +0300 Subject: [PATCH 2/2] docs: drop defaultProps rationale per review --- docs/Fields.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Fields.md b/docs/Fields.md index d1f17341883..52fe351fae7 100644 --- a/docs/Fields.md +++ b/docs/Fields.md @@ -499,7 +499,7 @@ export const FullNameField = (props) => { **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. 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: +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: ```jsx import { List, Datagrid } from 'react-admin';