Pagination broke after e6357bc
See original GitHub issueAfter: https://github.com/marmelab/react-admin/commit/e6357bcc95f53d588a8b44073c1dc22fcbcc9b85 Specifically: https://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/controller/useListController.ts#L187-L189
Broke my apps pagination. I wasn’t able to investigate too deeply but I think the root cause may have been that I mutate params inside it’s buildQuery
, so I think there may be a cache mismatch or something. defaultTotal
was correct, total
was undefined in the new change, forcing the page to continually setPage(1)
below.
What you were expecting: No breaking change from 3.7.1 to 3.8.1
What happened instead: Pagination broke
Steps to reproduce:
I can’t give a full reproduction presently, but a dataProvider
’s buildQuery
which mutates params
of a GET_LIST
Related code: Specifically: https://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/controller/useListController.ts#L187-L189
Environment
- React-admin version: 3.8.1
- Last version that did not exhibit the issue (if applicable): 3.7.1
- React version: ^16.9.0
- Browser: Chrome
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:12 (6 by maintainers)
Top GitHub Comments
As in JavaScript, objects are passed by reference, mutating params mutates the original object and may have nasty side effects.
What if you start by cloning the params before passing them to the query? something like:
Fixed by #5263