You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally reported on other issue, these likely share the same root cause: #4025 (comment)
What you were expecting:
Before react-admin 3.0, would render the available data regardless of the total item count.
What happened instead:
In react-admin 3.0, if total item count somehow ends up as NaN, the data is not shown. Instead, we get "Error: Too many re-renders."
Steps to reproduce:
I was using ra-data-simple-rest with a backend that provides content-range headers, but not total count of available items. For example: Content-Range: thingamajings 0-24/*
Next, ra-data-simple-rest fetches the total using total: parseInt(headers.get('content-range').split('/').pop(), 10). This results in total=NaN
Last important bit is in useQueryWithStore in ra-core: this checks for state updates using if (!isEqual(state.data, data) || state.total !== total) ... However, since total=NaN the second condition is never true. It thus always appears as if the fetched data has been updated, so this code attempts to update the related component. I don't have full details, how, but this results in scheduling updates over and over again, until the "Too many re-renders" check stops the loop.
Sample code
Example code here, based on the simple example: https://codesandbox.io/s/simple-t03vd
The only edits there are to dataProvider.js, to make it provide the problematic data.
Environment
React-admin version: 3.0.1
Last version that did not exhibit the issue (if applicable): 2.8.3
React version: 16.12.0
Browser: Chrome 78
The text was updated successfully, but these errors were encountered:
Originally reported on other issue, these likely share the same root cause: #4025 (comment)
What you were expecting:
Before react-admin 3.0, would render the available data regardless of the total item count.
What happened instead:
In react-admin 3.0, if total item count somehow ends up as NaN, the data is not shown. Instead, we get "Error: Too many re-renders."
Steps to reproduce:
I was using
ra-data-simple-rest
with a backend that provides content-range headers, but not total count of available items. For example:Content-Range: thingamajings 0-24/*
Next,
ra-data-simple-rest
fetches the total using total:parseInt(headers.get('content-range').split('/').pop(), 10)
. This results intotal=NaN
Last important bit is in
useQueryWithStore
inra-core
: this checks for state updates using if(!isEqual(state.data, data) || state.total !== total) ...
However, sincetotal=NaN
the second condition is never true. It thus always appears as if the fetched data has been updated, so this code attempts to update the related component. I don't have full details, how, but this results in scheduling updates over and over again, until the "Too many re-renders" check stops the loop.Sample code
Example code here, based on the
simple
example: https://codesandbox.io/s/simple-t03vdThe only edits there are to
dataProvider.js
, to make it provide the problematic data.Environment
The text was updated successfully, but these errors were encountered: