Scroll Restoration
Scroll Restoration Browsers are starting to handle scroll restoration with history. React-router-dom에서 Scroll Restoration 을 기본적으로 지원한다. 옵션엔 auto , manual이 있다. auto면 이미 방문한 곳의 이전 스크롤을 복원해준다. 현재 프로젝트에서 post list를 보는 곳은 스크롤이 복원되어야하지만, post 상세보기에서는 맨 위로 위치시켜야한다. 따라서 detail 페이지에 라우팅되었을 때 스크롤을 최상단으로 위치하는 함수를 추가해야한다. import { useEffect } from "react"; import { useLocation } from "react-router-dom"; exp..
프로그래밍/React
2021. 4. 30. 01:54
반응형
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
농담곰의 고군분투 개발기