Skip to content

Commit 8f170d2

Browse files
committed
fix: parse slugs
1 parent 04c1047 commit 8f170d2

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/contexts/FestivalEditionContext.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createContext, PropsWithChildren, useContext, useMemo } from "react";
2-
import { matchPath } from "react-router-dom";
2+
import { matchPath, useLocation } from "react-router-dom";
33
import { type Festival, type FestivalEdition } from "@/services/queries";
44
import {
55
useFestivalEditionBySlugQuery,
@@ -55,14 +55,17 @@ function getSlugs(pathname: string) {
5555
};
5656
}
5757

58+
function useParseSlugs() {
59+
const location = useLocation();
60+
const pathname = location.pathname;
61+
62+
return useMemo(() => getSlugs(pathname), [pathname]);
63+
}
64+
5865
export function FestivalEditionProvider({
5966
children,
6067
}: PropsWithChildren<unknown>) {
61-
const pathname = location.pathname;
62-
const { festivalSlug, editionSlug } = useMemo(
63-
() => getSlugs(pathname),
64-
[pathname],
65-
);
68+
const { festivalSlug, editionSlug } = useParseSlugs();
6669

6770
const festivalQuery = useFestivalBySlugQuery(festivalSlug);
6871

0 commit comments

Comments
 (0)