Skip to content

Commit 7af07fd

Browse files
committed
fix(webapp): prevent incidents URL being called every frame
1 parent 49de105 commit 7af07fd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

apps/webapp/app/routes/resources.incidents.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ExclamationTriangleIcon } from "@heroicons/react/20/solid";
22
import { json } from "@remix-run/node";
33
import { useFetcher } from "@remix-run/react";
44
import { motion } from "framer-motion";
5-
import { useCallback, useEffect } from "react";
5+
import { useCallback, useEffect, useRef } from "react";
66
import { LinkButton } from "~/components/primitives/Buttons";
77
import { Paragraph } from "~/components/primitives/Paragraph";
88
import { Popover, PopoverContent, PopoverTrigger } from "~/components/primitives/Popover";
@@ -26,12 +26,14 @@ export async function loader() {
2626
export function IncidentStatusPanel({ isCollapsed = false }: { isCollapsed?: boolean }) {
2727
const { isManagedCloud } = useFeatures();
2828
const fetcher = useFetcher<typeof loader>();
29+
const fetcherRef = useRef(fetcher);
30+
fetcherRef.current = fetcher;
2931

3032
const fetchIncidents = useCallback(() => {
31-
if (fetcher.state === "idle") {
32-
fetcher.load("/resources/incidents");
33+
if (fetcherRef.current.state === "idle") {
34+
fetcherRef.current.load("/resources/incidents");
3335
}
34-
}, [fetcher]);
36+
}, []);
3537

3638
useEffect(() => {
3739
if (!isManagedCloud) return;

0 commit comments

Comments
 (0)