-
React project structure articlesReact.js 2020. 11. 17. 11:05
React 튜터링을 위해 조사하며 찾은 좋은 article들을 모아봤다
1. medium.com/@Charles_Stover/optimal-file-structure-for-react-applications-f3e35ad0a145
"One of the most important and agreed upon structures for a React project is to have a components directory for storing your components. Some developers use two directories — one for stateful components and one for stateless components. As an opinionated article, I’ll discuss what I’ve found most intuitive: a single directory for components. Keep related code as close as possible. "
- Create-react-app에서 부터 project structure를 구성해나가는 것을 단계별로 보여준다.
- stateful component와 stateless component를 나누는 방법 대신에,
src 이하에 한 directory에 component들을 몰아넣으라고 조언하고 있는데,
"연관있는 코드는 가능한 가까이에" 라는 의견에 동의한다. - components 하위에 component 단위별로 directory를 생성해서 관련된 js, css, test를 다 모아놓는데,
모듈화 해서 프로그래밍 한다 - 라는 흐름이라고 보면 되겠지?
물론 실제 경험상 directory가 너무 많아도 번거롭고, 모두 flat하게 component 하위에 펼쳐져 있어도 문제이기도 하다. - file 이름을 모두 lower case로 작성하기를 권장하고 있다.
이는 "Most operating systems are case sensitive; always use lowercase."를 근거로 하고 있는데,
뭐 개발자의 실수로 "component.js" "Component.js" 두 파일이 생성될경우 혼란을 가져올수 있어서가 아닐까
... 따라서 lowercase만 써라~
'React.js' 카테고리의 다른 글
[React 튜터링 일지] React 기본 2주차 (0) 2020.12.03 [React 튜터링 일지] React 기본 1주차 (0) 2020.11.27 [초심자 튜터링] React의 render() 리턴에 대하여 (0) 2020.11.26 React Router에 대해서 내가 모르던 것들 (0) 2020.11.04 virtual DOM에 대해서 (0) 2020.10.20 - Create-react-app에서 부터 project structure를 구성해나가는 것을 단계별로 보여준다.