Partial Pagination Not Working for `ReferenceManyField`
See original GitHub issueWhat you were expecting:
When the getManyReference
method of the dataProvider
returns pageInfo
instead of total
, partial pagination should be in effect for the pagination component passed to the ReferenceManyField
component.
What happened instead:
When the getManyReference
method of the dataProvider
returns pageInfo
instead of total
, the pagination component passed to the ReferenceManyField
component does not render at all.
Steps to reproduce:
- Pass a
Pagination
component to theReferenceManyField
: https://marmelab.com/react-admin/ReferenceManyField.html#pagination - Have the
getManyReference
method of thedataProvider
returnpageInfo
instead oftotal
.
Other information:
This could be the culprit here as the pagination
prop is not rendered unless total
is defined.
Environment
- React-admin version: 4.0.1
- React version: 18.0.0
- Browser: Chrome 103.0.5060.134
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Pagination of `<ReferenceManyField>` · Issue #561 - GitHub
I just noticed that fetch all data was possible, so I commented to help people that might need it as a quick solution...
Read more >Passing props to ReferenceArrayField doesn't seem to work
When passing the pagination, perPage and sort props to reference array component they don't seem to be applied. I have a similar view...
Read more >react-admin/CHANGELOG and react-admin Releases (Page 2)
A frontend Framework for building B2B applications running in the browser on top of ... Fix <ReferenceManyField> does not show pagination when using...
Read more >Source - GitHub
... Fix `<ReferenceManyField>` does not show pagination when using partial pagination ([#8354](https://github.com/marmelab/react-admin/pull/8354)) ...
Read more >react-admin - Projects | FOSSA
... 7705-codesandbox-not-working-for-tutorial-example ... optional-basepath2; partial-pagination; pass-permissions-to-register-resource; password-input ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for this helpful and almost perfect reporting!
Could you provide a behaviour reproduction sandbox?
Many thanks for your help in this matter! 👍
For those who encounter this issue in the future, a workaround is to return
total
asnull
as part of thegetManyReference
method of thedataProvider
.As an example:
This works because the
ReferenceManyField
only renders the pagination controls iftotal !== undefined
as seen here:https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/field/ReferenceManyField.tsx#L92
For those who use TypeScript, you can use the
@ts-expect-error
or@ts-ignore
directives to suppress the type error that will arise (total
is expected to benumber
orundefined
).