Open
Conversation
- user, grade, exchangeRate, recentProduct 쿼리 분리 - queryKey와 queryFn 함께 정의하여 응집도 향상
- CurrencyProvider로 전역 통화 상태 관리 - QueryClient Suspense 기본 옵션 설정
- Header에서 useCurrencyContext로 통화 토글 연동 - PageLayout에서 Outlet을 CurrencyProvider, Suspense로 감싸기
- CurrentLevelSection 등급 진행률 계산 로직 - RecentPurchaseSection 통화 포맷팅 - 등급 계산 순수함수 utils로 추출 - Compound Components 패턴 적용 (.Skeleton, .Error)
- router에 errorElement로 전역 에러 처리 - 통화 토글 테스트 수정 (클릭 전/후 분리 assertion) - HTMLElement.textContent 정규식 매칭 수정 - 테스트 수정 내역 문서화
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.
📝 변경 사항 요약
iteration1 완료
설계 원칙
1. 상태 관리
Context 반환 형태는 useState와 유사한 배열로
useState가[value, setter]튜플을 반환하듯, 커스텀 Context도 동일한 패턴을 따르면 사용처에서 예측 가능합니다.2. Suspense & ErrorBoundary
핵심 원칙: 관심사의 수직 분리
컴포넌트가 처리해야 할 상태를 계층별로 분리합니다:
이 구조를 통해 각 컴포넌트는 자신의 성공 케이스에만 집중할 수 있습니다.
옵셔널 체이닝(
?.)이 코드 전체로 전염되는 것을 방지합니다.Compound Component 패턴
3. 컴포넌트 설계
단일 책임 원칙
JSX 내 조건문 최소화
4. SSOT (Single Source of Truth)
장점
주의
5. 이정표 vs 상수
구분 기준
"최근 구매한 상품"EXPLORER→ExplorerUI에서 "여기가 어디인지" 알려주는 텍스트는 그 자리에 있어야 가독성이 높아집니다. 모든 스트링 리터럴이 매직넘버가 아닙니다
6. 함수 설계
순수 함수로 로직 분리
7. Query Key Factory
원칙
queryKey와queryFn을 함께 정의현재 구조
현재 API들은 각각 독립적인 책임을 가지므로 별도 파일로 분리:
user.tsgrade.tsrecentProduct.tsexchangeRate.ts책임이 겹치거나 확장 시 연관성이 생기면 통합을 고려합니다.
8. 에러 처리
router.tsx의errorElementErrorBoundary+.Error컴포넌트9. 폴더 구조
iter03
1. CartProvider 액션 네이밍
addItem/removeItem→increaseQuantity/decreaseQuantity(수량 ±1)deleteItem→removeFromCart(완전 삭제)2. ProductInfoSection ↔ CartControlSection 분리
3. CartControls 컴파운드 패턴
isInCart분기를 상위에서 처리, 하위 컴포넌트는 각자 관심사만4. useLocalQuantity 훅 분리
CartControls.Add가 로컬 수량만 관심갖도록5. RecommendationSection 데이터 로직 분리
useRecommendedProducts훅으로 쿼리 + 계산 로직 추출useSuspenseQueries로 병렬 요청🤝 리뷰어에게
SSOT 요소를 coreBusiness 폴더로 분리했습니다
해당 컨벤션에 대해 어떻게 생각하시는지 궁금합니다!
레퍼런스: toss-fe-interview/frontend-fundamentals-mock-exam-1#80