From 11878f807c195ef5a533dd23a81e988e707ba7e5 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Fri, 26 Apr 2024 12:58:00 -0500 Subject: [PATCH] Improve swr key handling --- src/app/grid/page.tsx | 1 + src/app/page.tsx | 2 ++ src/photo/InfinitePhotoScroll.tsx | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/grid/page.tsx b/src/app/grid/page.tsx index b9c8258c..3a52c212 100644 --- a/src/app/grid/page.tsx +++ b/src/app/grid/page.tsx @@ -38,6 +38,7 @@ export default async function GridPage() { {photos.length >= INFINITE_SCROLL_MULTIPLE_GRID && {photos.length >= INFINITE_SCROLL_MULTIPLE_HOME && } diff --git a/src/photo/InfinitePhotoScroll.tsx b/src/photo/InfinitePhotoScroll.tsx index 897ac6de..a478e2ca 100644 --- a/src/photo/InfinitePhotoScroll.tsx +++ b/src/photo/InfinitePhotoScroll.tsx @@ -17,12 +17,14 @@ export type RevalidatePhoto = ( ) => Promise; export default function InfinitePhotoScroll({ + swrKey, type = 'full-frame', initialOffset = 0, itemsPerPage = 12, prefetch = true, triggerOnView = true, }: { + swrKey: string type?: 'full-frame' | 'grid' initialOffset?: number itemsPerPage?: number @@ -30,7 +32,7 @@ export default function InfinitePhotoScroll({ triggerOnView?: boolean debug?: boolean }) { - const key = type; + const key = `${swrKey}-${type}`; const buttonContainerRef = useRef(null);