-
Notifications
You must be signed in to change notification settings - Fork 46
[1팀 천진아] Chapter 3-3 기능 중심 아키텍처와 프로젝트 폴더 구조 #21
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
Open
totter15
wants to merge
19
commits into
hanghae-plus:main
Choose a base branch
from
totter15:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- entities 레이어에 store 및 비즈니스 로직 이동 - widgets UI 컴포넌트를 ui 폴더로 재구성 - dialog 상태 관리를 위한 store 추가 (useDetailPostDialogStore, useUserDialogStore) - PostsManagerPage에서 테이블 로직을 widgets로 분리 (usePostTable) - features와 entities 간 역할 분리 개선
- Post 관련 파라미터 관리 hooks를 features로 이동 - DetailPostDialog 상태 관리를 widgets로 이동 - PostParams 타입을 entities로 분리
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.
배포링크
https://totter15.github.io/front_7th_chapter3-3/
과제 체크포인트
기본과제
목표 : 전역상태관리를 이용한 적절한 분리와 계층에 대한 이해를 통한 FSD 폴더 구조 적용하기
체크포인트
심화과제
목표: 서버상태관리 도구인 TanstackQuery를 이용하여 비동기코드를 선언적인 함수형 프로그래밍으로 작성하기
체크포인트
최종과제
과제 셀프회고
fsd에 대해 설명만 읽었을때는 어떤기준을 사용해서 분리하는건지 알것 같았는데 막상 사용해보니 모호한 컴포넌트들, hook들이 생기면서 이게 feature인가? entities인가? 에 대해 계속 고민하게 되었던것 같습니다.
폴더를 나눈 기준
shared
entities
features
widgets
최종적으로는 아래의 폴더 구조를 만들었습니다.
이번 과제를 통해 이전에 비해 새롭게 알게 된 점이 있다면 적어주세요.
api dto와 ui의 type이 다를때 mapper를 사용하는법
api에서 user데이터를 조회했을때 필요없는 데이터가 너무 많이 조회되었습니다.
이걸 ui에서 쓰기엔 불필요하다 생각이 들었는데 찾아보니 mapper라는 중간 함수를 이용해서 dto를 ui에서 사용하는 props만 return하게 하는 방식이 있음을 알게되었습니다.
entities와 feature의 차이
과제 시작전 entities에 api함수가 들어가는지? 들어간다면 조회하는 api만 들어가는지? 수정,삭제등의 api도 들어가는지?에 대한 고민이 있었습니다. 이에 대한 기준을 세웠는데 기본적인 데이터api는 entities에 실제로 해당 데이터를 저장하고 상태로 관리하는건 useQuery를 통해 관리되기에 해당 api를 통한 상태관리를 하는 query는 features/api에 넣었습니다.
selectedPost/selectedUser에 대해서도 상태관리 store를 따로 뒀는데 이둘 또한 선택된 게시글, 선택된 유저의 상태라는 entity라 생각되어 entities 계층에 두었습니다.
feature과 widgets의 차이
feature은 하나의 기능 widgets는 여러개의 기능이 복합적으로 사용됨을 기준으로 폴더를 분리했습니다.
아직은 막연하다거나 더 고민이 필요한 부분을 적어주세요.
원래 action함수들을 props으로 내려주는 형식으로 코드를 많이 작성하는데 이번에는 하나의 기능을 가진 컴포넌트가 되도록 내부에서 hook을 호출하는 방식으로 작업을 진행했습니다. 이렇게 했을때 이 컴포넌트가 외부에 의존하지 않으니 어디든 이동하기엔 쉬운데 이 컴포넌트 자체를 테스트하기 어려운 형태가 아닐까 생각이 듭니다. 어떨때에 props로 내려주고 어떨때에 내부 hook을 이용할지에 대해 좀더 고민이 필요할 것 같습니다.
챕터 셀프회고
클린코드: 읽기 좋고 유지보수하기 좋은 코드 만들기
결합도 낮추기: 디자인 패턴, 순수함수, 컴포넌트 분리, 전역상태 관리
응집도 높이기: 서버상태관리, 폴더 구조
리뷰 받고 싶은 내용이나 궁금한 것에 대한 질문
어떤경우에 컴포넌트에서 props로 내려받고 어떤경우에 hook으로 기능을 내부에 구현하면 좋을까요? 이번과제에서는 feature/ui, widget/ui는 모두 내부에 hook으로 함수를 호출해서 독립적인 컴포넌트가 될수있도록 만들어 주었습니다. 하지만 이렇게 하니 테스트하기가 어려워 지는게 아닌가란 생각이 듭니다.
제가 잡은 fsd 폴더 기준이 통용적으로 사용되는 기준일까요? 아니면 실제로 제가 세운 기준과는 다르게 사용이 될까요?