diff --git a/docs/Fields.md b/docs/Fields.md index 8446467b15b..b6d9f867fdd 100644 --- a/docs/Fields.md +++ b/docs/Fields.md @@ -482,12 +482,10 @@ Here is a custom field displaying the full name: ```jsx import { useRecordContext } from 'react-admin'; -export const FullNameField = (props) => { +export const FullNameField = ({ label = 'Name', ...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`.