Skip to content

Commit 663d7ea

Browse files
authored
Add check to call initial users only once in dev mode (#332)
1 parent b701783 commit 663d7ea

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/contexts/ApplicationProvider.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import FullScreenLoading from "@components/ui/FullScreenLoading";
33
import { useApiCall } from "@utils/api";
44
import { useIsMd } from "@utils/responsive";
55
import { getLatestNetbirdRelease } from "@utils/version";
6-
import React, { useContext, useEffect, useMemo, useState } from "react";
6+
import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
77
import { useLocalStorage } from "@/hooks/useLocalStorage";
88
import { User } from "@/interfaces/User";
99
import type { NetbirdRelease } from "@/interfaces/Version";
@@ -31,12 +31,16 @@ export default function ApplicationProvider({ children }: Props) {
3131
const isMd = useIsMd();
3232
const userRequest = useApiCall<User[]>("/users", true);
3333
const [show, setShow] = useState(false);
34+
const requestCalled = useRef(false);
3435

3536
useEffect(() => {
36-
userRequest
37-
.get()
38-
.then(() => setShow(true))
39-
.catch(() => setShow(true));
37+
if (!requestCalled.current) {
38+
userRequest
39+
.get()
40+
.then(() => setShow(true))
41+
.catch(() => setShow(true));
42+
requestCalled.current = true;
43+
}
4044
// eslint-disable-next-line react-hooks/exhaustive-deps
4145
}, []);
4246

0 commit comments

Comments
 (0)