Skip to content

Commit

Permalink
Fix: Infinite loop (#9)
Browse files Browse the repository at this point in the history
* use next_public env vars

* fix: rm array from dependencies

* use server side secret variables
  • Loading branch information
gmguarino authored Apr 24, 2024
1 parent 9dc654c commit 85fd4b7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ const TopCountriesSection = () => {
data: [],
layout: {},
});
const fetchGraphData = async () => {
const mapResponse = await fetchData("graphs", "evolution-map");
setMapData(mapResponse);
};
useEffect(() => {
const fetchGraphData = async () => {
const mapResponse = await fetchData("graphs", "evolution-map");
setMapData(mapResponse);
};
fetchGraphData();
}, [mapData]);
}, []);

if (!mapData) {
return <></>;
Expand Down
11 changes: 5 additions & 6 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,13 @@ const BusinessSection = () => {
data: [],
layout: {},
});

const fetchGraphData = async () => {
const response = await fetchData("graphs", "hyper-growth-grouped");
setPlot(response);
};
useEffect(() => {
const fetchGraphData = async () => {
const response = await fetchData("graphs", "hyper-growth-grouped");
setPlot(response);
};
fetchGraphData();
}, [plot]);
}, []);

if (!plot) {
return <></>;
Expand Down
3 changes: 2 additions & 1 deletion src/components/DashboardSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const DashboardSection = ({
data: [],
layout: {},
});

const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
const fetchGraphData = async () => {
Expand All @@ -34,7 +35,7 @@ const DashboardSection = ({
}
};
fetchGraphData();
}, [chartData, id]);
}, [id]);

if (!chartData) {
return <></>;
Expand Down
11 changes: 5 additions & 6 deletions src/components/JoinBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ const IntroBlock = ({
data: [],
layout: {},
});

const fetchGraphData = async () => {
const response = await fetchData("graphs", "alternatives");
setPlot(response);
};
useEffect(() => {
const fetchGraphData = async () => {
const response = await fetchData("graphs", "alternatives");
setPlot(response);
};
fetchGraphData();
}, [plot]);
}, []);

if (!plot) {
return <></>;
Expand Down
1 change: 1 addition & 0 deletions src/pages/api/chart.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use server";
export const fetchData = async (apiPath: string, chartName: string) => {

const dataUrl = process.env.PINKBOMBS_DATA_URL;
Expand Down

0 comments on commit 85fd4b7

Please sign in to comment.