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
This commit is contained in:
Justin Edmund 2024-04-22 07:01:40 -07:00
parent 7a6105b19f
commit a1f556583a
4 changed files with 19 additions and 31 deletions

View file

@ -171,7 +171,7 @@ export const useTeamFilter = (
isFetching, isFetching,
setFetching, setFetching,
fetchError, fetchError,
fetchTeams, fetch,
processTeams, processTeams,
currentPage, currentPage,
setCurrentPage, setCurrentPage,

View file

@ -8,7 +8,6 @@ import InfiniteScroll from 'react-infinite-scroll-component'
// Hooks // Hooks
import { useFavorites } from '~hooks/useFavorites' import { useFavorites } from '~hooks/useFavorites'
import { useTeamFilter } from '~hooks/useTeamFilter' import { useTeamFilter } from '~hooks/useTeamFilter'
import useDidMountEffect from '~hooks/useDidMountEffect'
// Utils // Utils
import fetchLatestVersion from '~utils/fetchLatestVersion' import fetchLatestVersion from '~utils/fetchLatestVersion'
@ -75,7 +74,7 @@ const ProfileRoute: React.FC<Props> = ({
isFetching, isFetching,
setFetching, setFetching,
fetchError, fetchError,
fetchTeams, fetch,
processTeams, processTeams,
setPagination, setPagination,
} = useTeamFilter(CollectionPage.Profile, context) } = useTeamFilter(CollectionPage.Profile, context)
@ -83,20 +82,17 @@ const ProfileRoute: React.FC<Props> = ({
const { toggleFavorite } = useFavorites(parties, setParties) const { toggleFavorite } = useFavorites(parties, setParties)
// Set the initial parties from props // Set the initial parties from props
useDidMountEffect(() => { useEffect(() => {
if (context) { if (context) {
if (context.teams && context.pagination) { fetch(true)
processTeams(context.teams, true)
setPagination(context.pagination)
appState.raidGroups = context.raidGroups appState.raidGroups = context.raidGroups
appState.version = version appState.version = version
} }
}
setCurrentPage(1) setCurrentPage(1)
setFetching(false) setFetching(false)
}, [context]) }, [])
// Fetch all raids on mount, then find the raid in the URL if present // Fetch all raids on mount, then find the raid in the URL if present
useEffect(() => { useEffect(() => {

View file

@ -8,7 +8,6 @@ import InfiniteScroll from 'react-infinite-scroll-component'
// Hooks // Hooks
import { useFavorites } from '~hooks/useFavorites' import { useFavorites } from '~hooks/useFavorites'
import { useTeamFilter } from '~hooks/useTeamFilter' import { useTeamFilter } from '~hooks/useTeamFilter'
import useDidMountEffect from '~hooks/useDidMountEffect'
// Utils // Utils
import fetchLatestVersion from '~utils/fetchLatestVersion' import fetchLatestVersion from '~utils/fetchLatestVersion'
@ -70,7 +69,7 @@ const SavedRoute: React.FC<Props> = ({
isFetching, isFetching,
setFetching, setFetching,
fetchError, fetchError,
fetchTeams, fetch,
processTeams, processTeams,
setPagination, setPagination,
} = useTeamFilter(CollectionPage.Saved, context) } = useTeamFilter(CollectionPage.Saved, context)
@ -78,20 +77,17 @@ const SavedRoute: React.FC<Props> = ({
const { toggleFavorite } = useFavorites(parties, setParties) const { toggleFavorite } = useFavorites(parties, setParties)
// Set the initial parties from props // Set the initial parties from props
useDidMountEffect(() => { useEffect(() => {
if (context) { if (context) {
if (context.teams && context.pagination) { fetch(true)
processTeams(context.teams, true)
setPagination(context.pagination)
appState.raidGroups = context.raidGroups appState.raidGroups = context.raidGroups
appState.version = version appState.version = version
} }
}
setCurrentPage(1) setCurrentPage(1)
setFetching(false) setFetching(false)
}, [context]) }, [])
// Fetch all raids on mount, then find the raid in the URL if present // Fetch all raids on mount, then find the raid in the URL if present
useEffect(() => { useEffect(() => {

View file

@ -9,7 +9,6 @@ import InfiniteScroll from 'react-infinite-scroll-component'
// Hooks // Hooks
import { useFavorites } from '~hooks/useFavorites' import { useFavorites } from '~hooks/useFavorites'
import { useTeamFilter } from '~hooks/useTeamFilter' import { useTeamFilter } from '~hooks/useTeamFilter'
import useDidMountEffect from '~hooks/useDidMountEffect'
// Utils // Utils
import fetchLatestVersion from '~utils/fetchLatestVersion' import fetchLatestVersion from '~utils/fetchLatestVersion'
@ -67,7 +66,7 @@ const TeamsRoute: React.FC<Props> = ({
isFetching, isFetching,
setFetching, setFetching,
fetchError, fetchError,
fetchTeams, fetch,
processTeams, processTeams,
setPagination, setPagination,
} = useTeamFilter(CollectionPage.Teams, context) } = useTeamFilter(CollectionPage.Teams, context)
@ -75,20 +74,17 @@ const TeamsRoute: React.FC<Props> = ({
const { toggleFavorite } = useFavorites(parties, setParties) const { toggleFavorite } = useFavorites(parties, setParties)
// Set the initial parties from props // Set the initial parties from props
useDidMountEffect(() => { useEffect(() => {
if (context) { if (context) {
if (context.teams && context.pagination) { fetch(true)
processTeams(context.teams, true)
setPagination(context.pagination)
appState.raidGroups = context.raidGroups appState.raidGroups = context.raidGroups
appState.version = version appState.version = version
} }
}
setCurrentPage(1) setCurrentPage(1)
setFetching(false) setFetching(false)
}, [context]) }, [])
// Fetch all raids on mount, then find the raid in the URL if present // Fetch all raids on mount, then find the raid in the URL if present
useEffect(() => { useEffect(() => {