diff options
| author | FifthWit <fifthwitbusiness@gmail.com> | 2025-01-30 10:46:30 -0600 |
|---|---|---|
| committer | FifthWit <fifthwitbusiness@gmail.com> | 2025-01-30 10:46:30 -0600 |
| commit | 73fc6a3d576222fcb7bce3f0e53cd8cd4b1d6428 (patch) | |
| tree | f7ab35b5f8c02d80456d15c352aa20760973cd49 /frontend/src | |
| parent | formatted with prettier (diff) | |
| download | lphub-73fc6a3d576222fcb7bce3f0e53cd8cd4b1d6428.tar.gz lphub-73fc6a3d576222fcb7bce3f0e53cd8cd4b1d6428.tar.bz2 lphub-73fc6a3d576222fcb7bce3f0e53cd8cd4b1d6428.zip | |
fixed rendering issue with useCallback
Diffstat (limited to 'frontend/src')
| -rw-r--r-- | frontend/src/App.tsx | 19 |
1 files changed, 10 insertions, 9 deletions
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 @@ | |||
| 1 | import React from 'react'; | 1 | import React, { useCallback } from 'react'; |
| 2 | import { Routes, Route } from 'react-router-dom'; | 2 | import { Routes, Route } from 'react-router-dom'; |
| 3 | import { Helmet } from 'react-helmet'; | 3 | import { Helmet } from 'react-helmet'; |
| 4 | 4 | ||
| @@ -26,9 +26,7 @@ const App: React.FC = () => { | |||
| 26 | undefined | 26 | undefined |
| 27 | ); | 27 | ); |
| 28 | const [isModerator, setIsModerator] = React.useState<boolean>(false); | 28 | const [isModerator, setIsModerator] = React.useState<boolean>(false); |
| 29 | |||
| 30 | const [games, setGames] = React.useState<Game[]>([]); | 29 | const [games, setGames] = React.useState<Game[]>([]); |
| 31 | |||
| 32 | const [uploadRunDialog, setUploadRunDialog] = React.useState<boolean>(false); | 30 | const [uploadRunDialog, setUploadRunDialog] = React.useState<boolean>(false); |
| 33 | 31 | ||
| 34 | const _fetch_token = async () => { | 32 | const _fetch_token = async () => { |
| @@ -41,12 +39,15 @@ const App: React.FC = () => { | |||
| 41 | setGames(games); | 39 | setGames(games); |
| 42 | }; | 40 | }; |
| 43 | 41 | ||
| 44 | const _set_profile = async (user_id?: string) => { | 42 | const _set_profile = useCallback( |
| 45 | if (user_id && token) { | 43 | async (user_id?: string) => { |
| 46 | const user = await API.get_profile(token); | 44 | if (user_id && token) { |
| 47 | setProfile(user); | 45 | const user = await API.get_profile(token); |
| 48 | } | 46 | setProfile(user); |
| 49 | }; | 47 | } |
| 48 | }, | ||
| 49 | [token] | ||
| 50 | ); | ||
| 50 | 51 | ||
| 51 | React.useEffect(() => { | 52 | React.useEffect(() => { |
| 52 | if (token === undefined) { | 53 | if (token === undefined) { |