Skip to content

[DNM] Remove ListIterator #10880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open

[DNM] Remove ListIterator #10880

wants to merge 28 commits into from

Conversation

erwanMarmelab
Copy link
Contributor

Problem

ListIterator has a drawback: empty, loading and error states appear inside the wrapper (often a <ul>). It makes it unusable in most cases.

Solution

  • remove the component
  • update <SingleFieldList> and <SimpleList> to not use it
  • Update WithListContext to accept optional empty, loading and error components
  • Add a ListIterator alias for WithListcontext

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

Copy link
Contributor

@Madeorsk Madeorsk left a comment

Choose a reason for hiding this comment

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

Does SimpleList still works when you pass data manually? It doesn't seem to be used and tested anymore.

Also, this is missing:

  • Update WithListContext to accept optional empty, loading and error components

Copy link
Contributor

@Madeorsk Madeorsk left a comment

Choose a reason for hiding this comment

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

A few issues related to WithListContext.

Copy link
Contributor

@Madeorsk Madeorsk left a comment

Choose a reason for hiding this comment

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

Nearly done!

</ReferenceArrayFieldBase>
</ListIterator>
</ListBase>
<ListBase
Copy link
Member

Choose a reason for hiding this comment

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

This code isn't better than the previous one. It underlines the fact that RecordsIterator should probably return null while loading, without any warning.


export interface WithListContextProps<RecordType extends RaRecord> {
if (isPending === true && loading) {
Copy link
Member

Choose a reason for hiding this comment

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

loading=null is a valid ReactNode and should be taken into account. I thing you should change the test to be as in https://github.com/marmelab/react-admin/pull/10864/files#diff-cdac9daf5ac7f12fe651a4357b777c27564f7372b0387256dd630f0a9d07c479

hasTertiaryText={!!tertiaryText}
/>
}
empty={empty ?? <></>}
Copy link
Member

Choose a reason for hiding this comment

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

should be empty ?? null IMO

render={({ data }) => (
<Root className={className} {...sanitizeListRestProps(rest)}>
<RecordsIterator
data={data}
Copy link
Member

Choose a reason for hiding this comment

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

I don't know why you need data here

{...sanitizeListRestProps(rest)}
>
<RecordsIterator
data={data}
Copy link
Member

Choose a reason for hiding this comment

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

same

@fzaninotto fzaninotto changed the title Remove ListIterator [DNM] Remove ListIterator Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Development

Successfully merging this pull request may close these issues.

3 participants