This project directory structure is domain driven, so subdirectories of src
directory are either related to some domain or are "common".
src
│ App.tsx
│ index.css
│ index.tsx
│ routes.tsx
│
└── common
│ └── components
│ └── hooks
│ └── layouts
│ └── models
│ └── routes
│ └── utils
│
└── domain
│ └── components
│ └── hooks
│ └── layouts
│ └── models
│ └── routes
│ └── utils
│
└── other domain
│ └── ...
Subdirectories of domain:
components
– components that are common to the domain; used by componentsroutes
hooks
– common hookslayouts
– layouts; used byroutes
models
– data types; used byapi
andcomponents
routes
– route indexes (index.tsx
files) and components used to render them (files other thanindex.tsx
)utils
– helpers that are none of the above
Above directories may group files into further subdirectories to group related functionalities. However, subdirectory depth should not exceed 1 more level, with exception to route indexes paths, that should follow URL pathname for easier file navigation.
Read "Create React App" section.
Follow the Conventional Commits Specification.
- Prettier
// import from node_modules first
import Dependency from 'dependency'
// * leave blank line *
// import from project using absolute path, base dir is parent of `src` directory
import AbsolutePath from 'components/absolute/path'
// * leave blank line *
// import from project using relative path
import RelativePath from '../relative/path'
This project was bootstrapped with Create React App.
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.