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.
This commit is contained in:
Aurora Lahtela 2023-03-19 09:37:09 +02:00
parent c2000db8de
commit c4058d3edb
1 changed files with 1 additions and 1 deletions

View File

@ -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};