Skip to content

Commit

Permalink
Merge pull request #4097 from marmelab/Fix-total-nan
Browse files Browse the repository at this point in the history
Fix incorrect dataProvider leads to infinite render loop
  • Loading branch information
djhi authored Dec 3, 2019
2 parents 3141cc8 + 24508a9 commit 3f6ce19
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/ra-core/src/dataProvider/useQueryWithStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,18 @@ const useQueryWithStore = (
loaded: data !== undefined && !isEmptyList(data),
});
if (!isEqual(state.data, data) || state.total !== total) {
setState({
...state,
data,
total,
loaded: true,
});
if (isNaN(total)) {
console.error(
'Total from response is not a number. Please check your dataProvider or the API.'
);
} else {
setState({
...state,
data,
total,
loaded: true,
});
}
}
const dataProvider = useDataProvider();
useEffect(() => {
Expand Down

0 comments on commit 3f6ce19

Please sign in to comment.