-
Notifications
You must be signed in to change notification settings - Fork 1
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/#308: 사용자의 전공 상태 정보(useState) 삭제 #309
Conversation
- 리액트 훅으로 관리하기 위해 사용했던 타입을 삭제
- getMajor : 로컬 스토리지에서 사용자의 전공을 가져옴 - setMajor : 초기 전공을 설정하거나, 전공을 변경할 경우 로컬 스토리지에 새로운 전공을 저장
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전공값 조회/수정을 모두 localStorage 를 이용하는데 Provider 로 굳이 감싸지 않고 Util 로 사용하는건 어떤가요??
|
학과가 변경되는 경우 리렌더링에 관한 문제는 없을까요?? |
상태를 사용하지 않기 때문에, 새로고침하지 않는 한 리렌더링은 발생 안하지 않을까요? 리액트에서 컴포넌트가 리렌더링 되는 경우는 리액트 훅으로 관리하는 상태가 변경되었을 때인데, 로컬 스토리지를 사용하기 때문에 리렌더링은 발생 안할 것 같네요. 그리고, 학과가 변경 되었을 때도 정상적으로 동작하는 걸 확인 했습니다 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ 좋아요~
🤠 개요
useState
) 로 관리할 필요는 없다고 판단해서 로컬 스토리지에 의존하는 클래스를 구현해서 관리하는 것으로 변경 했어요.💫 설명
클래스를 사용해서 로컬 스토리지에 저장한 사용자의 전공 정보를 관리하고,
MajorProvider
컴포넌트는 해당 클래스를 의존성으로 주입해줬어요. 주입 받는 컴포넌트들은 동일하게useMajor
훅을 사용해서 전공 정보를 참조할 수 있어요📷 스크린샷 (Optional)