From 8c4492beb86a75989f9a5ade5e5729177069ddf4 Mon Sep 17 00:00:00 2001 From: KJ Shanks Date: Wed, 31 Jul 2024 18:47:43 -0400 Subject: [PATCH] Fix app crash when navigating to let them dj when signed out --- .../ExploreCollectionsPageProvider.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/web/src/pages/explore-page/ExploreCollectionsPageProvider.tsx b/packages/web/src/pages/explore-page/ExploreCollectionsPageProvider.tsx index 0a3459fafa6..025af91402e 100644 --- a/packages/web/src/pages/explore-page/ExploreCollectionsPageProvider.tsx +++ b/packages/web/src/pages/explore-page/ExploreCollectionsPageProvider.tsx @@ -44,6 +44,11 @@ const ExploreCollectionsPageProvider = ({ children: Children }: ExploreCollectionsPageProviderProps) => { const { location } = useHistory() + const match = matchPath<{ + mood: string + }>(getPathname(location), { + path: EXPLORE_MOOD_PLAYLISTS_PAGE + }) const [info, setInfo] = useState< ExploreCollection | ExploreMoodCollection | null >(null) @@ -51,12 +56,7 @@ const ExploreCollectionsPageProvider = ({ useEffect(() => { if (variant === ExploreCollectionsVariant.MOOD) { // Mood playlist - const match = matchPath<{ - mood: string - }>(getPathname(location), { - path: EXPLORE_MOOD_PLAYLISTS_PAGE - }) - if (match && match.params.mood) { + if (match?.params.mood) { const collectionInfo = EXPLORE_MOOD_COLLECTIONS_MAP[match.params.mood] fetch(variant, collectionInfo.moods) setInfo(collectionInfo) @@ -68,7 +68,8 @@ const ExploreCollectionsPageProvider = ({ fetch(variant) setInfo(EXPLORE_COLLECTIONS_MAP[variant]) } - }, [variant, fetch, location]) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [variant, fetch]) const title = info ? info.variant === ExploreCollectionsVariant.MOOD