From c4058d3edbb686b1a9c9c384904f4744f3f3b692 Mon Sep 17 00:00:00 2001 From: Aurora Lahtela <24460436+AuroraLS3@users.noreply.github.com> Date: Sun, 19 Mar 2023 09:37:09 +0200 Subject: [PATCH] Fixed data was not updating on page change When switching from any page with a shared data fetch method between server and network, such as join address graph, the network page would not update the data, since the identifier is not in the parameter list. This was fixed by also checking parameters.length in useEffect dependencies. --- Plan/react/dashboard/src/hooks/dataFetchHook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plan/react/dashboard/src/hooks/dataFetchHook.js b/Plan/react/dashboard/src/hooks/dataFetchHook.js index c1fa680c6..077b62593 100644 --- a/Plan/react/dashboard/src/hooks/dataFetchHook.js +++ b/Plan/react/dashboard/src/hooks/dataFetchHook.js @@ -59,7 +59,7 @@ export const useDataRequest = (fetchMethod, parameters) => { fetchMethod(updateRequested, ...parameters).then(({data: json, error}) => { handleResponse(json, error, false, 1000); }); - }, [fetchMethod, ...parameters, updateRequested, refreshBarrierMs]) + }, [fetchMethod, parameters.length, ...parameters, updateRequested, refreshBarrierMs]) /* eslint-enable react-hooks/exhaustive-deps */ return {data, loadingError};