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,
setFetching,
fetchError,
fetchTeams,
fetch,
processTeams,
currentPage,
setCurrentPage,

View file

@ -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<Props> = ({
isFetching,
setFetching,
fetchError,
fetchTeams,
fetch,
processTeams,
setPagination,
} = useTeamFilter(CollectionPage.Profile, context)
@ -83,20 +82,17 @@ const ProfileRoute: React.FC<Props> = ({
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(() => {

View file

@ -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<Props> = ({
isFetching,
setFetching,
fetchError,
fetchTeams,
fetch,
processTeams,
setPagination,
} = useTeamFilter(CollectionPage.Saved, context)
@ -78,20 +77,17 @@ const SavedRoute: React.FC<Props> = ({
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(() => {

View file

@ -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<Props> = ({
isFetching,
setFetching,
fetchError,
fetchTeams,
fetch,
processTeams,
setPagination,
} = useTeamFilter(CollectionPage.Teams, context)
@ -75,20 +74,17 @@ const TeamsRoute: React.FC<Props> = ({
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(() => {