From 24508a9cc4a7eb50a3072f11275bf1b8276c0793 Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Mon, 2 Dec 2019 16:18:14 +0100 Subject: [PATCH] Fix incorrect dataProvider leads to infinite render loop Closes #4094 --- .../src/dataProvider/useQueryWithStore.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/ra-core/src/dataProvider/useQueryWithStore.ts b/packages/ra-core/src/dataProvider/useQueryWithStore.ts index 8f5a06720dd..3647f5c9642 100644 --- a/packages/ra-core/src/dataProvider/useQueryWithStore.ts +++ b/packages/ra-core/src/dataProvider/useQueryWithStore.ts @@ -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(() => {