From 80169f1803f3f28d9b62cb2bbb36609480f3981c Mon Sep 17 00:00:00 2001 From: Chuck Dries <chuck@chuckdries.com> Date: Tue, 7 Mar 2023 23:48:49 -0800 Subject: [PATCH] WIP history and such not quite working (404ing) --- src/pages/photogallery.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/photogallery.tsx b/src/pages/photogallery.tsx index 4806e0a..9af7d19 100644 --- a/src/pages/photogallery.tsx +++ b/src/pages/photogallery.tsx @@ -41,9 +41,11 @@ function smartCompareDates( return compareDates(SORT_KEYS.date, left, right); } -const GalleryPage = ({ data }: PageProps<Queries.GalleryPageQueryQuery>) => { - const hash = - typeof window !== "undefined" ? window.location.hash.replace("#", "") : ""; +const GalleryPage = ({ data, location }: PageProps<Queries.GalleryPageQueryQuery>) => { + // const hash = + // typeof window !== "undefined" ? window.location.hash.replace("#", "") : ""; + + const hash = location.hash ? location.hash.replace("#", "") : ""; const [hashCleared, setHashCleared] = React.useState(false); // eslint-disable-line no-unused-vars // ^ used just to force a re-render with the cleared hash value (I know, it's a smell for sure) @@ -141,7 +143,7 @@ const GalleryPage = ({ data }: PageProps<Queries.GalleryPageQueryQuery>) => { // don't scroll into view if user got here with back button scrollIntoView(); }, 100); - }, [setSortKey, setKeyword, scrollIntoView]); + }, [setSortKey, setKeyword, scrollIntoView, location]); const images: GalleryImage[] = React.useMemo(() => { const sort =