Skip to content

Add render prop page and reference MUI components#10837

Merged
fzaninotto merged 26 commits intonextfrom
marmelab/listRenderProp
Jul 22, 2025
Merged

Add render prop page and reference MUI components#10837
fzaninotto merged 26 commits intonextfrom
marmelab/listRenderProp

Conversation

@ThieryMichel
Copy link
Copy Markdown
Contributor

@ThieryMichel ThieryMichel commented Jul 15, 2025

follow #10832

Problem

When doing custom UI, having to read the ListContext forces to create a separate component, or to use WithListContext. For really custom UIs, it feels like an unnecessary indirection.

const PagesList = () => (
   <List>
       <ul>
           <WithListContext render={({ data }) =>
               data.map(page => (
                   <li key={page.id}>
                       <Link to={page.url}>{page.title}</Link>
                   </li>
               ))
           } />
       </ul>
   </List>
);

Solution

Support a render prop that renders inside the created context, but also passes the context as argument.

const PagesList = () => (
   <List render={({ data }) =>
      <ul>{data.map(page => (
            <li key={page.id}>
               <Link to={page.url}>{page.title}</Link>
            </li>
      ))}</ul>} />
   </List>
);

This prop is optional. When absent, the component falls back to using children .

Concerned components:

  • List
  • Edit
  • Create
  • Show
  • InfiniteList
  • ReferenceField
  • ReferenceManyField
  • ReferenceArrayField
  • ReferenceOneField
    Add stories and documentation for these props.

Excluded (not necessary):

  • SingleFieldList

How To Test

Describe the steps required to test the changes

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date

Also, please make sure to read the contributing guidelines.

@ThieryMichel ThieryMichel force-pushed the marmelab/listRenderProp branch from ff912e8 to 5add7d5 Compare July 17, 2025 16:27
@ThieryMichel ThieryMichel added the RFR Ready For Review label Jul 17, 2025
Base automatically changed from marmelab/renderprops-with-context to next July 21, 2025 15:32
@fzaninotto fzaninotto changed the title Marmelab/add render prop on MUI component Marmelab/add render prop to MUI component Jul 21, 2025
@fzaninotto fzaninotto changed the title Marmelab/add render prop to MUI component Add render prop page and reference MUI components Jul 21, 2025
@fzaninotto fzaninotto merged commit 82d0cd6 into next Jul 22, 2025
15 checks passed
@fzaninotto fzaninotto deleted the marmelab/listRenderProp branch July 22, 2025 08:25
@fzaninotto fzaninotto added this to the 5.10.0 milestone Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants