refactor: TimeTable 최적화 (비동기 처리, 경쟁 조건 해소, 코드 위생)#2
Open
Conversation
- usePostTimeSlot에서 mutateAsync 노출 (createTimeSlotAsync) - handleSaveClick을 async/await로 변경하여 mutation 완료 대기 - refetch() 제거 (onSuccess에서 setQueryData로 캐시 업데이트 중이므로 불필요) - onEditModeChange는 mutation 성공 후 호출 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- selectedCarId/selectedWeek deps를 공유하는 두 개의 useEffect를 단일 effect로 병합 - handleCancelClick 호출 대신 직접 상태 초기화 수행 (deps 변경에 의한 불필요한 effect 재실행 방지) - rAF로 displayWeek 전환 + showSlots 복원을 단일 effect에서 관리 - window.requestAnimationFrame → requestAnimationFrame 통일 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- AvailableTimeSlot: hover useState → CSS :hover로 전환 (슬롯당 리렌더링 2회 → 0회) - AvailableTimeSlot: 삭제 버튼 opacity: 0 → :hover opacity: 1 패턴 적용 - slotMerger: includes 참조 비교 → slotUtils.isSameSlot 값 비교로 수정 - slotUtils: 미사용 removeSlot, addSlot 함수 제거 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TimeTable 컴포넌트의 버그, 경쟁 조건, 코드 중복, 미사용 코드를 개선합니다.
Commit 1: handleSaveClick 비동기 처리 및 불필요한 API 호출 제거
usePostTimeSlot에서mutateAsync노출handleSaveClick을async/await로 변경하여 mutation 완료 대기refetch()제거 (onSuccess에서setQueryData로 캐시 업데이트 중이므로 불필요)Commit 2: useEffect 경쟁 조건 해소 - 중복 effect 통합
selectedCarId,selectedWeek)를 가진 2개의 useEffect를 1개로 병합handleCancelClick호출 대신 직접 상태 초기화 (deps 변경에 의한 불필요한 재실행 방지)window.requestAnimationFrame→requestAnimationFrame통일Commit 3: 코드 위생 개선
useState→ CSS:hover로 전환 (슬롯당 리렌더링 2회 → 0회)includes참조 비교 →slotUtils.isSameSlot값 비교로 수정removeSlot,addSlot함수 제거Test Plan
pnpm build— TypeScript 컴파일 에러 없음 확인pnpm test— 기존 테스트 통과 확인pnpm lint— lint 에러 없음 확인🤖 Generated with Claude Code