Skip to content

Commit

Permalink
Merge pull request #364 from adhocteam/js-fix-overview-multi-request
Browse files Browse the repository at this point in the history
Fix overview multi request
  • Loading branch information
jasalisbury authored Jul 20, 2021
2 parents d1db645 + 348e8d7 commit 5a8e7eb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions frontend/src/widgets/withWidgetData.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ const withWidgetData = (Widget, widgetId) => {
region, allRegions, loadingOverride, skipLoading, errorOverride,
} = props;

const selectedRegion = region || allRegions[0];

useEffect(() => {
const fetch = async () => {
try {
updateLoading(true);
const requestedRegion = region || allRegions[0];
const fetchedData = await fetchWidget(widgetId, requestedRegion);
const fetchedData = await fetchWidget(widgetId, selectedRegion);
updateData(fetchedData);
updateError('');
} catch (e) {
Expand All @@ -34,7 +35,7 @@ const withWidgetData = (Widget, widgetId) => {
}
};
fetch();
}, [region, allRegions]);
}, [selectedRegion]);

if ((loading || loadingOverride) && !skipLoading) {
return (
Expand Down

0 comments on commit 5a8e7eb

Please sign in to comment.