Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] ScrollRestoration 사용을 위한 react router v6.4 data router 도입 #346

Merged
merged 3 commits into from
Oct 23, 2023

Conversation

yoopark
Copy link
Contributor

@yoopark yoopark commented Oct 21, 2023

Summary

React Router v6.4에서 소개된 data router 방식으로 교체하였습니다.

Ref. https://reactrouter.com/en/main/start/overview

Describe your changes

변경한 라우터로 모든 페이지 오류 없음을 확인하였습니다.

ScrollRestoration이라는 아주 좋은 기능을 사용하기 위해서는 React Router v6.4의 data router 방식으로 사용해야 했기 때문에 교체하였고, 예상보다 더 쉽게 잘 되어버려서 바로 PR을 올립니다.

ScrollRestoration은 location.key를 키로 하기 때문에, 쿼리 스트링의 변화도 다른 페이지로 잘 인식합니다❗️

Ref. https://reactrouter.com/en/main/components/scroll-restoration

Issue number and link

Router 바깥에서 useLocation을 호출할 수 없어 일단 ScrollToTop을 무력화하였습니다.
어차피 ScrollToTop은 곧 ScrollRestoration을 위해 삭제될 예정이었습니다.

See also #319
@yoopark yoopark added bug Something isn't working enhancement New feature or request labels Oct 21, 2023
@yoopark yoopark requested a review from 42sungwook October 21, 2023 19:00
@yoopark yoopark self-assigned this Oct 21, 2023
Copy link
Contributor

@42sungwook 42sungwook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getkey 옵션을 안하면 페이지 전체가 적용되나보네여👍

@yoopark yoopark merged commit 96ee218 into develop Oct 23, 2023
@yoopark yoopark deleted the refactor/react-router-v6.4 branch October 23, 2023 02:24
@42sungwook 42sungwook mentioned this pull request Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

뒤로가기할 때 스크롤이 맨 위로 이동하는 문제
2 participants