Note: this guide assumes you are using typescript.
- General folder structure
- Naming general rules
- Naming inside a feature folder
- Naming
-
common // keeps all the things that are being used in more than one feature
- assets // images, icons
- components // the most basic components
- constants // global magic values
- hooks // consider using react-use library
- models //
- services
- util-service.ts
- store // connects all the other stores
-
features
- feature-name
-
layout // components that are used in the entire app, e.g., navigation, footer
-
pages // all the pages that you have
-
styles // global styles
- variables.css
CamelCasefor component name.kebab-casefor folder and file names.CAPS_LOOKfor constantsIPersonfor custom interfacesIPersonTemperamentfor custom types
Let's image we have a feature that named todo.
All the component folders will be prefixed with todo
e.g. , todo-item or todo-item-lite
All the files from todo feature will be prefixed with todo.
- component example
todo-item.tsxortodo-item-lite.tsx - in constants folder:
todo-constants.ts - in models folder :
todo-models.ts - in services folder:
todo-api-service.tsandtodo-util-service.ts - in store folder:
todo-store
Why? It's easier to search and keeps things consistent.
All the component names will be prefixed with Todo
e.g. TodoItem or TodoItemLite
Why? For consistency it's better to prefix them with the feature name.
Why ?