Skip to content

docs: update field component example to use modern React patterns - #10699

Closed
dhfra21 wants to merge 1 commit into
marmelab:masterfrom
dhfra21:fix/update-field-docs-defaultprops
Closed

dhfra21 wants to merge 1 commit into
marmelab:masterfrom
dhfra21:fix/update-field-docs-defaultprops

Conversation

@dhfra21

@dhfra21 dhfra21 commented Apr 25, 2025

Copy link
Copy Markdown

Problem

 The documentation currently recommends using defaultProps for function components, which is being removed in React 19.

 ## Solution
 Update the example to use modern React patterns with parameter destructuring and default values.

 ## Additional Checks
 - [x] The PR targets `master` for a documentation fix
 - [x] The documentation is up to date

Comment thread docs/Fields.md
import { useRecordContext } from 'react-admin';

export const FullNameField = (props) => {
export const FullNameField = ({ label = 'Name', ...props }) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't work. Datagrid and SimpleShowLayout inspect the label prop of their child, and a default value defined as you describe cannot be read by the parent.

@fzaninotto

Copy link
Copy Markdown
Member

No news for some time, closing.

@fzaninotto fzaninotto closed this Jul 21, 2025

This branch was successfully deployed

1 active deployment
Preview – react-admin-storybook — aec35dad Deployed Apr 25, 2025 by vercel[bot]
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.

2 participants