react-admin: Editing a record throws Total from response is not a number error

What you were expecting:

Expect it won’t log any error in console when changing filter on a ReferenceManyField What happened instead:

Total from response is not a number error is shown in console when filter prop is changed on ReferenceManyField Steps to reproduce:

  1. Go to codesandbox https://codesandbox.io/s/elastic-surf-urpjz
  2. Edit a post -> go to comments tab
  3. I added a body filter to filter comments in the comments tab in PostEdit.js. Change the body filter by typing some characters
  4. Total from response is not a number. Please check your dataProvider or the API error is thrown in console

Screenshot 2020-01-22 at 1 25 38 PM

Related code:

https://codesandbox.io/s/elastic-surf-urpjz

Other information:

This is the line which throws the error https://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/dataProvider/useQueryWithStore.ts#L121.

I wonder if the check here https://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/dataProvider/useQueryWithStore.ts#L119-L120 is suitable for useGetManyReference / ReferenceManyField.

When the filter prop is changed, useGetManyReference will use a new relatedTo to select ids & total from store, but we are comparing them against the old relatedTo (generated using old filter prop)'s ids & total.

Environment

  • React-admin version: Latest
  • Last version that did not exhibit the issue (if applicable):
  • React version:
  • Browser:
  • Stack trace (in case of a JS error):
Total from response is not a number. Please check your dataProvider or the API. 
    in Anonymous (at PostEdit.js:151)
    in PostEdit (created by WithPermissions)
    in WithPermissions (created by Router.Consumer)
    in Router.Consumer (created by Route)
    in Route (created by ResourceRoutes)
    in ResourceRoutes (created by Resource)
    in Resource (at src/​index.js:40)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 22 (13 by maintainers)

Most upvoted comments

Same error using BulkDeleteButton and redirect to a list view

Okay I have reproduced it. v3.3.0 solved the ReferenceManyField issue but the same error appears multiple times after I update a post. Attached gif:

ezgif-7-f86b878b8525

The bug was introduced in 3.3.0 It’s happens only if undoable={true] We’re working on it

I use react-admin 3.3.0 and I still have this error.

Same error when I edit one element

But it’s fixed in 3.3.3, right?

Same error using DeleteButton and BulkDeleteButton. Also, I get this error afterwards: TypeError: record is undefined - with deletemany there shouldn’t be a single record. Also, a valid response from delete and deleteMany (according to the docs) is null.