From bfb03d08eed6eb1affd1525e3537221fe08a72e3 Mon Sep 17 00:00:00 2001 From: Hyeonsu Kim Date: Fri, 30 Aug 2024 12:23:17 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20after=20loading=20=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A1=A4=20=EB=B3=B5=EC=9B=90=20=ED=9B=85=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useScrollRestoration.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hooks/useScrollRestoration.ts b/src/hooks/useScrollRestoration.ts index 0409af26..d3b22b19 100644 --- a/src/hooks/useScrollRestoration.ts +++ b/src/hooks/useScrollRestoration.ts @@ -36,7 +36,10 @@ export default function useScrollRestoration() { } export const restoreScrollPosition = (router: NextRouter) => { - const scrollPos = JSON.parse(sessionStorage.getItem(router.asPath) || '{"x": 0, "y": 0}'); + //const scrollPos = JSON.parse(sessionStorage.getItem(router.asPath) || '{"x": 0, "y": 0}'); + const scrollPos = JSON.parse('{"x": 0, "y": 0}'); // router.asPath 가 기록된 경우, 페이지 재진입 시 scroll 이 아래쪽으로 기억되어 있는 문제가 발생 + + console.log(scrollPos); window.scroll(scrollPos.x, scrollPos.y); };