Summary
This command line help you create your React Native project in a easy and useful structure by creating components and screens in separate folders in order to distinguish between them. It also make it easier to create navigations for your screens without writing a single line of code.
The following project structure is used by this command:
src
├───components
│ ├───comp-one
│ │ index.jsx
│ │ styles.js
│ │
│ ├───comp-two
│ │ index.jsx
│ │ styles.js
│ │
│ └───folder
│ └───comp-three
│ index.jsx
│ styles.js
│
├───redux
│ │ index.js
│ │
│ ├───actions
│ │ └───general
│ │ index.js
│ │
│ └───reducers
│ │ index.js
│ │
│ └───general
│ index.js
│
└───screens
│ navigation.jsx
│
├───folder
│ │ navigation.jsx
│ │
│ ├───screen-four
│ │ │ index.jsx
│ │ │ styles.js
│ │ │
│ │ └───functions
│ │ index.js
│ │
│ └───screen-three
│ │ index.jsx
│ │ styles.js
│ │
│ └───functions
│ index.js
│
├───screen-one
│ │ index.jsx
│ │ styles.js
│ │
│ └───functions
│ index.js
│
└───screen-two
│ index.jsx
│ styles.js
│
└───functions
index.js
As you can see above, the
srcfolder is the folder that resides at the root of your React Native project and under this folder, you will find thecomponentsfolder which contains all the shared components that are used through out the screen. Thescreensfolder contains the app's screens that can uses some of the shared components above it.In each component you will find
index.jsxthat contains the componentsJSX.Elementsyntaxes, andstyles.jsthat contains the styles for that component.In each screen you will find
index.jsxthat contains theJSX.Elementsyntaxes, andstyles.jsthat contains the screen's styles andfunctionsfolder which will contain the screen's specific functions.Each screen can use one of the shared components that are defined in
componentsfolder, and you can pass the functions to those components hence there is notfunctionsfolder under a component subfolder.For the
screenspart you can findnavigation.jsxfiles that shows the relation between the screens that resides in the same folder. For example, thenavigation.jsxunder thescreensfolder represent a stack navigation betweenfolderandscreen-oneandscreen-two. As for thenavigation.jsxfile under thefolderfolder is represent a drawer navigation betweenscreen-threeandscreen-four.As for the
reduxfolder you can see there isindex.jswhich contain the redux store, andactionsandreducersfolders are next to it so you can find only things that are related to redux in one single place.This command line can write code in both JavaScript and TypeScript. By default it will use the used language for your React Native project and of course you can override the used language using one of its options.