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

[시간표] 커스텀 시간표 페이지 리팩터링 #656

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from

Conversation

Gwak-Seungju
Copy link
Contributor

@Gwak-Seungju Gwak-Seungju commented Feb 13, 2025

What is this PR? 🔍

Changes 📝

@ChoiWonBeen 님의 피드백을 받고 정리한 관련 노션입니다.
관련 스레드입니다.

아무래도 노션에서 정리한 5번6번을 중점적으로 리뷰해주시면 될 것 같습니다.

5번 내용은 지금까지 CustomLecture라는 폼 컨테이너에 모든 state를 넣고 관리했는데 시간과 장소를 묶는 컨테이너를 컴포넌트화할 필요가 있다하여 TimeSpaceInput이라는 이름으로 컴포넌트화했습니다.

6번 내용은 useEffect를 줄일 수 있으면 줄여라 였는데, 결과적으로는 더 늘리는 꼴이 되었습니다. 그 이유는 아래와 같습니다.
customTempLecture라는 현재 커스텀 일정의 정보를 담고 있는 객체를 전역 상태로 관리하고 있습니다. 이 객체가 하는 역할은 그 강의 정보를 시간표에 미리보기볼 수 있도록 하는 것입니다. 따라서 form을 업데이트 할 때마다 customTempLecture도 즉각 업데이트를 해줘야 하는데, 컴포넌트를 분리하다 보니 자식, 부모, 컴포넌트에서 updateCustomLecture를 해야 하는 상황이 있었습니다.
"한 줄 요약"
컴포넌트화해서
-> 해결했습니다.

솔직히 잘 리팩터링한 건 지는 모르겠습니다... 코드 길이도 이전보다 100줄 정도 늘어나기도 해서..

✔️ Please check if the PR fulfills these requirements

  • It's submitted to the correct branch, not the develop branch unconditionally?
  • If on a hotfix branch, ensure it targets main?
  • There are no warning message when you run yarn lint

@Gwak-Seungju Gwak-Seungju added 🔨 Refactor 코드 리팩토링 👤 User 유저, 시간표 도메인 labels Feb 13, 2025
@Gwak-Seungju Gwak-Seungju self-assigned this Feb 13, 2025
Comment on lines 84 to 90
const findKeyByValue = (object: Record<Hour, number>, value: number) => Object
.entries(object).find(([, val]) => val === value)?.[0] as Hour;
const getHour = (time: number, key: Record<Hour, number>, isStart: boolean) => {
const adjustedTime = time % 2 === (isStart ? 0 : 1) ? time : time - 1;
return findKeyByValue(key, adjustedTime);
};
const getMinute = (time: number, isStart: boolean): Minute => (time % 2 === (isStart ? 0 : 1) ? '00분' : '30분');
Copy link
Member

Choose a reason for hiding this comment

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

이런 함수는 react의 생명주기 안에 있을 필요가 없는 것 같아욤

Copy link
Contributor Author

Choose a reason for hiding this comment

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

앗! 그렇네요! 반영했습니다! 2e8fccf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 Refactor 코드 리팩토링 👤 User 유저, 시간표 도메인
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[시간표] 커스텀 시간표 페이지 리팩터링
2 participants