From a1f556583a0fba0c4341a25ef879af58fd9d9fe0 Mon Sep 17 00:00:00 2001 From: Justin Edmund <383021+jedmund@users.noreply.github.com> Date: Mon, 22 Apr 2024 07:01:40 -0700 Subject: [PATCH] Remove useDidMountEffect For some reason, this isn't actually firing. We are now using `useEffect` instead and fetching the first set of data when the page loads --- hooks/useTeamFilter.tsx | 2 +- pages/[username].tsx | 16 ++++++---------- pages/saved.tsx | 16 ++++++---------- pages/teams.tsx | 16 ++++++---------- 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/hooks/useTeamFilter.tsx b/hooks/useTeamFilter.tsx index ac6cf9f6..07866c5b 100644 --- a/hooks/useTeamFilter.tsx +++ b/hooks/useTeamFilter.tsx @@ -171,7 +171,7 @@ export const useTeamFilter = ( isFetching, setFetching, fetchError, - fetchTeams, + fetch, processTeams, currentPage, setCurrentPage, diff --git a/pages/[username].tsx b/pages/[username].tsx index c7bd0323..70e1396f 100644 --- a/pages/[username].tsx +++ b/pages/[username].tsx @@ -8,7 +8,6 @@ import InfiniteScroll from 'react-infinite-scroll-component' // Hooks import { useFavorites } from '~hooks/useFavorites' import { useTeamFilter } from '~hooks/useTeamFilter' -import useDidMountEffect from '~hooks/useDidMountEffect' // Utils import fetchLatestVersion from '~utils/fetchLatestVersion' @@ -75,7 +74,7 @@ const ProfileRoute: React.FC = ({ isFetching, setFetching, fetchError, - fetchTeams, + fetch, processTeams, setPagination, } = useTeamFilter(CollectionPage.Profile, context) @@ -83,20 +82,17 @@ const ProfileRoute: React.FC = ({ const { toggleFavorite } = useFavorites(parties, setParties) // Set the initial parties from props - useDidMountEffect(() => { + useEffect(() => { if (context) { - if (context.teams && context.pagination) { - processTeams(context.teams, true) - setPagination(context.pagination) + fetch(true) - appState.raidGroups = context.raidGroups - appState.version = version - } + appState.raidGroups = context.raidGroups + appState.version = version } setCurrentPage(1) setFetching(false) - }, [context]) + }, []) // Fetch all raids on mount, then find the raid in the URL if present useEffect(() => { diff --git a/pages/saved.tsx b/pages/saved.tsx index 35a59d93..8a71b722 100644 --- a/pages/saved.tsx +++ b/pages/saved.tsx @@ -8,7 +8,6 @@ import InfiniteScroll from 'react-infinite-scroll-component' // Hooks import { useFavorites } from '~hooks/useFavorites' import { useTeamFilter } from '~hooks/useTeamFilter' -import useDidMountEffect from '~hooks/useDidMountEffect' // Utils import fetchLatestVersion from '~utils/fetchLatestVersion' @@ -70,7 +69,7 @@ const SavedRoute: React.FC = ({ isFetching, setFetching, fetchError, - fetchTeams, + fetch, processTeams, setPagination, } = useTeamFilter(CollectionPage.Saved, context) @@ -78,20 +77,17 @@ const SavedRoute: React.FC = ({ const { toggleFavorite } = useFavorites(parties, setParties) // Set the initial parties from props - useDidMountEffect(() => { + useEffect(() => { if (context) { - if (context.teams && context.pagination) { - processTeams(context.teams, true) - setPagination(context.pagination) + fetch(true) - appState.raidGroups = context.raidGroups - appState.version = version - } + appState.raidGroups = context.raidGroups + appState.version = version } setCurrentPage(1) setFetching(false) - }, [context]) + }, []) // Fetch all raids on mount, then find the raid in the URL if present useEffect(() => { diff --git a/pages/teams.tsx b/pages/teams.tsx index 611fe524..50b65eb1 100644 --- a/pages/teams.tsx +++ b/pages/teams.tsx @@ -9,7 +9,6 @@ import InfiniteScroll from 'react-infinite-scroll-component' // Hooks import { useFavorites } from '~hooks/useFavorites' import { useTeamFilter } from '~hooks/useTeamFilter' -import useDidMountEffect from '~hooks/useDidMountEffect' // Utils import fetchLatestVersion from '~utils/fetchLatestVersion' @@ -67,7 +66,7 @@ const TeamsRoute: React.FC = ({ isFetching, setFetching, fetchError, - fetchTeams, + fetch, processTeams, setPagination, } = useTeamFilter(CollectionPage.Teams, context) @@ -75,20 +74,17 @@ const TeamsRoute: React.FC = ({ const { toggleFavorite } = useFavorites(parties, setParties) // Set the initial parties from props - useDidMountEffect(() => { + useEffect(() => { if (context) { - if (context.teams && context.pagination) { - processTeams(context.teams, true) - setPagination(context.pagination) + fetch(true) - appState.raidGroups = context.raidGroups - appState.version = version - } + appState.raidGroups = context.raidGroups + appState.version = version } setCurrentPage(1) setFetching(false) - }, [context]) + }, []) // Fetch all raids on mount, then find the raid in the URL if present useEffect(() => {