From 73fc6a3d576222fcb7bce3f0e53cd8cd4b1d6428 Mon Sep 17 00:00:00 2001 From: FifthWit Date: Thu, 30 Jan 2025 10:46:30 -0600 Subject: fixed rendering issue with useCallback --- frontend/src/App.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'frontend') diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 754f5a2..4a99625 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useCallback } from 'react'; import { Routes, Route } from 'react-router-dom'; import { Helmet } from 'react-helmet'; @@ -26,9 +26,7 @@ const App: React.FC = () => { undefined ); const [isModerator, setIsModerator] = React.useState(false); - const [games, setGames] = React.useState([]); - const [uploadRunDialog, setUploadRunDialog] = React.useState(false); const _fetch_token = async () => { @@ -41,12 +39,15 @@ const App: React.FC = () => { setGames(games); }; - const _set_profile = async (user_id?: string) => { - if (user_id && token) { - const user = await API.get_profile(token); - setProfile(user); - } - }; + const _set_profile = useCallback( + async (user_id?: string) => { + if (user_id && token) { + const user = await API.get_profile(token); + setProfile(user); + } + }, + [token] + ); React.useEffect(() => { if (token === undefined) { -- cgit v1.2.3