diff options
| author | FifthWit <fifthwitbusiness@gmail.com> | 2025-01-30 11:24:17 -0600 |
|---|---|---|
| committer | FifthWit <fifthwitbusiness@gmail.com> | 2025-01-30 11:24:17 -0600 |
| commit | ff0496ee96c403f3665618dedc6bd7c0f90b5b51 (patch) | |
| tree | 4a802331b0c7fce17a0aa675e1fd9cd48675ea2d /frontend/src/pages | |
| parent | added missing dep and commented out _set_leaderboard_type() as its unused (diff) | |
| download | lphub-ff0496ee96c403f3665618dedc6bd7c0f90b5b51.tar.gz lphub-ff0496ee96c403f3665618dedc6bd7c0f90b5b51.tar.bz2 lphub-ff0496ee96c403f3665618dedc6bd7c0f90b5b51.zip | |
boom, fixed missing useEffect deps
Diffstat (limited to '')
| -rw-r--r-- | frontend/src/pages/User.tsx | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/frontend/src/pages/User.tsx b/frontend/src/pages/User.tsx index b6dfbd3..29d0041 100644 --- a/frontend/src/pages/User.tsx +++ b/frontend/src/pages/User.tsx | |||
| @@ -47,7 +47,7 @@ const User: React.FC<UserProps> = ({ token, profile, gameData }) => { | |||
| 47 | const location = useLocation(); | 47 | const location = useLocation(); |
| 48 | const navigate = useNavigate(); | 48 | const navigate = useNavigate(); |
| 49 | 49 | ||
| 50 | const _fetch_user = async () => { | 50 | const _fetch_user = React.useCallback(async () => { |
| 51 | const userID = location.pathname.split('/')[2]; | 51 | const userID = location.pathname.split('/')[2]; |
| 52 | if (token && profile && profile.profile && profile.steam_id === userID) { | 52 | if (token && profile && profile.profile && profile.steam_id === userID) { |
| 53 | navigate('/profile'); | 53 | navigate('/profile'); |
| @@ -55,9 +55,9 @@ const User: React.FC<UserProps> = ({ token, profile, gameData }) => { | |||
| 55 | } | 55 | } |
| 56 | const userData = await API.get_user(userID); | 56 | const userData = await API.get_user(userID); |
| 57 | setUser(userData); | 57 | setUser(userData); |
| 58 | }; | 58 | }, [location.pathname, token, profile, navigate]); |
| 59 | 59 | ||
| 60 | const _get_game_chapters = async () => { | 60 | const _get_game_chapters = React.useCallback(async () => { |
| 61 | if (game !== '0') { | 61 | if (game !== '0') { |
| 62 | const gameChapters = await API.get_games_chapters(game); | 62 | const gameChapters = await API.get_games_chapters(game); |
| 63 | setChapterData(gameChapters); | 63 | setChapterData(gameChapters); |
| @@ -65,9 +65,9 @@ const User: React.FC<UserProps> = ({ token, profile, gameData }) => { | |||
| 65 | setPageMax(Math.ceil(user!.records.length / 20)); | 65 | setPageMax(Math.ceil(user!.records.length / 20)); |
| 66 | setPageNumber(1); | 66 | setPageNumber(1); |
| 67 | } | 67 | } |
| 68 | }; | 68 | }, [game, user]); |
| 69 | 69 | ||
| 70 | const _get_game_maps = async () => { | 70 | const _get_game_maps = React.useCallback(async () => { |
| 71 | if (chapter === '0') { | 71 | if (chapter === '0') { |
| 72 | const gameMaps = await API.get_game_maps(game); | 72 | const gameMaps = await API.get_game_maps(game); |
| 73 | setMaps(gameMaps); | 73 | setMaps(gameMaps); |
| @@ -79,23 +79,23 @@ const User: React.FC<UserProps> = ({ token, profile, gameData }) => { | |||
| 79 | setPageMax(Math.ceil(gameChapters.maps.length / 20)); | 79 | setPageMax(Math.ceil(gameChapters.maps.length / 20)); |
| 80 | setPageNumber(1); | 80 | setPageNumber(1); |
| 81 | } | 81 | } |
| 82 | }; | 82 | }, [chapter, game]); |
| 83 | 83 | ||
| 84 | React.useEffect(() => { | 84 | React.useEffect(() => { |
| 85 | _fetch_user(); | 85 | _fetch_user(); |
| 86 | }, [location]); | 86 | }, [location, _fetch_user]); |
| 87 | 87 | ||
| 88 | React.useEffect(() => { | 88 | React.useEffect(() => { |
| 89 | if (user) { | 89 | if (user) { |
| 90 | _get_game_chapters(); | 90 | _get_game_chapters(); |
| 91 | } | 91 | } |
| 92 | }, [user, game, location]); | 92 | }, [user, game, location, _get_game_chapters]); |
| 93 | 93 | ||
| 94 | React.useEffect(() => { | 94 | React.useEffect(() => { |
| 95 | if (user && game !== '0') { | 95 | if (user && game !== '0') { |
| 96 | _get_game_maps(); | 96 | _get_game_maps(); |
| 97 | } | 97 | } |
| 98 | }, [user, game, chapter, location]); | 98 | }, [user, game, chapter, location, _get_game_maps]); |
| 99 | 99 | ||
| 100 | if (!user) { | 100 | if (!user) { |
| 101 | return <></>; | 101 | return <></>; |