MLH-Fellowship / react-native-tutorial

6 stars 0 forks source link

Set up the file structure #11

Closed XifeiNi closed 3 years ago

XifeiNi commented 3 years ago

Set up the basic project structure

StuffByLiang commented 3 years ago

3 different possibilities in my opinion for the file structure (taken from https://www.reactnative.express/app/project_structure)

Small Project Structure All Components go under a component folder. Benefits: easy, everything in one directory.

MyApp
├── components
│   ├── Avatar.js
│   ├── Button.js
│   └── List.js
└── App.js

Medium Projects We start to categorize components into folders, for organization

MyApp
├── components
│   ├── buttons
│   │   ├── RoundButton.js
│   │   └── SquareButton.js
│   ├── cards
│   │   ├── ArticleCard.js
│   │   ├── ImageCard.js
│   │   └── VideoCard.js
│   ├── Component1.js
│   └── Component2.js
├── screens
│   ├── Screen1.js
│   ├── Screen2.js
├── styles
├── navigation
├── utils
└── App.js

Large projects All features are separated into their own folders at the top level with subfolders for components, screens, etc

MyApp
├── modules
│   ├── accounts
│   │   ├── components
│   │   │   ├── UserProfile.js
│   │   │   └── LoginInput.js
│   │   ├── screens
│   │   │   ├── Profile.js
│   │   │   ├── Login.js
│   │   │   └── Deactivate.js
│   │   ├── utils
│   │   │   └── formatAccountName.js
│   │   └── App.js
│   ├── growth
│   │   ├── components
│   │   ├── screens
│   │   ├── utils
│   │   └── App.js
│   ├── privacy
│   │   ├── components
│   │   ├── screens
│   │   ├── utils
│   │   └── App.js
│   └── shared
│       ├── components
│       │   ├── Avatar.js
│       │   ├── Button.js
│       │   └── List.js
│       └── utils
│           └── format.js
└── App.js

Proposal

I think the Medium project structure works well for our purposes. In addition, we'll put all files we're working in a src directory to further distinguish these are the main files that make up our app.

StuffByLiang commented 3 years ago

From the meeting: The large project structure is actually the best practice. We can include refactoring in the tutorial

eg. adding/building more screens -> this is becoming more unmanageable, lets refactor

princiya commented 3 years ago

also, given that we have to think about the branching model for the tutorial, it might be worth having the large project structure so that each module can be a tutorial step.