Skip to content

Commit 9b477dc

Browse files
committed
Fixes a devin suggestion for calling a react hook too early
1 parent 5b7c900 commit 9b477dc

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ export async function loader() {
2525

2626
export function IncidentStatusPanel({ isCollapsed = false }: { isCollapsed?: boolean }) {
2727
const { isManagedCloud } = useFeatures();
28-
if (!isManagedCloud) {
29-
return null;
30-
}
31-
3228
const fetcher = useFetcher<typeof loader>();
3329

3430
const fetchIncidents = useCallback(() => {
@@ -38,16 +34,18 @@ export function IncidentStatusPanel({ isCollapsed = false }: { isCollapsed?: boo
3834
}, [fetcher]);
3935

4036
useEffect(() => {
37+
if (!isManagedCloud) return;
38+
4139
fetchIncidents();
4240

4341
const interval = setInterval(fetchIncidents, 60 * 1000); // 1 minute
4442

4543
return () => clearInterval(interval);
46-
}, []);
44+
}, [isManagedCloud, fetchIncidents]);
4745

4846
const operational = fetcher.data?.operational ?? true;
4947

50-
if (operational) {
48+
if (!isManagedCloud || operational) {
5149
return null;
5250
}
5351

0 commit comments

Comments
 (0)