원문 : Practical Redux 과정의 리덕스 메인테이너가 쓴 글
https://www.educative.io/courses/practical-redux/gxkVE8NEvXj
Thoughts on Folder Structure - Practical Redux
www.educative.io
- 파일 타입 우선
- /reducers, /components 등과 같은 폴더
- 기능 우선
- "파드(pods)", "도메인(domain) 기반" 또는 "feature 폴더"
- 각 기능에 관련한 모든 파일 유형이 있는 폴더 구조
- 모든 폴더에 "actions.js" 및 "reducer.js"라는 이름의 파일을 두는 것보다 파일에 고유한 전체 이름을 지정하는 것을 선호합니다.
- 이것은 주로 편집기 탭에서 파일을 쉽게 찾고 파일 이름을 읽기 위한 것입니다.
- 또한 컴포넌트 파일의 이름을 SomeComponent/index.js로 지정하는 대신 고유한 이름을 지정하고 싶습니다
- modalReducer.js
- 나는 index.js 파일을 사용하여 중첩 폴더에 대한 일종의 "공개 API"로 함수와 구성 요소를 위로 다시 내보내는 실험을 했습니다.
- 잠시 후에 설명하지만 이 아이디어에 완전히 매료돤 것은 아닙니다.
- 이 폴더를 컨테이너가 아닌 feature라는 폴더 아래에 그룹화했습니다.
- 저는 개인적으로 사이드 이펙트를 위해 썽크와 사가를 혼합하여 사용합니다.
- 간단한 비동기 및 복잡한 동기 작업에는 썽크를 사용하고
- 더 복잡한 비동기 또는 분리된 논리에는 saga를 사용합니다.
- 나는 또한 다단계 상대 가져오기보다 "features/someFeature/SomeComponent"와 같은 "절대 가져오기"를 사용하는 것을 선호합니다.
- feature 롤더 옆에 있는 소스의 최상위 수준에 common 폴더가 있습니다.
- 여기에 응용 프로그램 전체의 여러 위치에서 재사용될 수 있는 정말 일반적인 재사용 가능한 구성 요소,
- 유틸리티 기능 및 기타 논리를 배치합니다.
- 이 경우 가져오기 경로를 단축하고
- 앱의 다른 부분이 가져온 컴포넌트가 단일 컴포넌트 파일인지 아니면
- 실제런 같은 폴더 내에 있는 여러 파일인 "컴파운드 컴포넌트"인지 대해 무지하게 유지합니다.
프로젝트 구조에 대한 논의는 아래에서 더 찾아볼 수 있습니다.
https://github.com/markerikson/react-redux-links/blob/master/project-structure.md
GitHub - markerikson/react-redux-links: Curated tutorial and resource links I've collected on React, Redux, ES6, and more
Curated tutorial and resource links I've collected on React, Redux, ES6, and more - GitHub - markerikson/react-redux-links: Curated tutorial and resource links I've collected on React, Redu...
github.com
GitHub - markerikson/react-redux-links: Curated tutorial and resource links I've collected on React, Redux, ES6, and more
Curated tutorial and resource links I've collected on React, Redux, ES6, and more - GitHub - markerikson/react-redux-links: Curated tutorial and resource links I've collected on React, Redu...
github.com
참고
레퍼런스 프로젝트
https://github.com/markerikson/project-minimek-educative
GitHub - markerikson/project-minimek-educative: A sample app to demonstrate various useful Redux techniques, accompanying the "P
A sample app to demonstrate various useful Redux techniques, accompanying the "Practical Redux" course on Educative.io - GitHub - markerikson/project-minimek-educative: A sample app to de...
github.com
리덕스 공식 문서
Code Structure | Redux
Table of Contents
redux.js.org
추가 팁
cra에서 .env에 아래와 같이 설정하면 기본 임포트 모드를 절대 경로로 활성화 한다 합니다.
저는 src 폴더에서 시작하는 "절대 가져오기" 경로를 일관되게 사용하는 것을 선호합니다.
무엇보다도 상대 가져오기 경로에 비해 파일을 쉽게 이동할 수 있습니다.
NODE_PATH=src
'FrontEnd' 카테고리의 다른 글
[3분 리액트] ref prop의 콜백 타입을 사용해 useEffect 사용 대체하기 (0) | 2022.08.18 |
---|---|
CREATE-REACT-APP에서 절대경로 임포트 사용하기 with typescript (1) | 2022.08.12 |
[publishing] 유용한 과거의 CSS와 타이포그래피 (0) | 2022.08.09 |
[CSS] 쌓임 맥락(스태킹 컨텍스트)과 z-index (0) | 2022.08.08 |
[3분 리액트] React18 Suspense의 Streaming SSR에 대해 알아보자 (0) | 2022.08.03 |