Bootstrap your React Navive App on the right foot with a set of widely accepted best practices in this opinionated template for React Native CLI.
Requirement | Dependencies | Platform | Notes |
---|---|---|---|
React Native Environment Setup | Node.js Node Runtime Watchman Dev hot reload file watcher npx bootstrap npm wrapper |
All | Follow React Native environment setup guide to install dependencies. |
Xcode | Xcode CLI Tools | OSX | Must use a Mac to build for iOS. Includes iOS simulator to run your apps. |
android studio | All | Includes Android simulator to run your apps. |
Note: Same steps as react-native cli. Shown here for convenience.
Recommendation: Use
npx
instead ofnpm
to execute react-native cli.
git clone https://github.com/davidmiura/RNCoreFoundation.git
npx react-native init my_cool_app --npm --template file:///<full_path_to_RNCoreFoundation_clone>
React-native builds my_cool_app using npm and the template. It will run npm install
for the provided package.json to install npm packages.
See: Example Log
Note: Same steps as react-native cli. Shown here for convenience.
cd my_cool_app
npx react-native run-ios
You should see overall build progress in the console. React-native will perform pod install
for the ios\podfile. The build process will launch a React Native Metro Server which serves your JS app to the device. The build will also install and launch your app in the iOS simulator.
See: Example Log
List iOS simulator devices
xcrun simctl list devices
Build and deploy to specific device
npx react-native run-ios --simulator="iPhone 11 Pro Max"
npm install
cd ios
pod install
cd ..
npm run ios
Note: Same steps as react-native cli. Shown here for convenience.
Requires Android Studio
cd my_cool_app
npx react-native run-android
Best Practice | Method | Configuration | Command | Notes |
---|---|---|---|---|
Type Safety | TypeScript | tsconfig.json |
||
Linting | ESLint | .eslintrc.js |
npm run lint npm run lint-fix |
|
Unit Testing | Jest | package.json |
npm run test | |
Code Formatting | Prettier | .prittierrc.js |
npm run lint-fix | |
Code Promotion Quality | Husky | package.json |
git commit git push |
Git Hooks |
Best Practice | Method | Notes |
---|---|---|
UX Component Lib | React Native Paper | Material Design UX Style |
Navigation | React Navigation v5 |
Best Practice | Method | Notes |
---|---|---|
Authentication | TBD | 3rd Party Provider |
Authorization | TBD/RBAC | Make a lib/service suggestion! |
API Access Control | JWT Bearer Token | RFC 7523 |
Best Practice | Method | Notes |
---|---|---|
App State Management | Redux Toolkit | Wrapper for Redux |
API | Graphql | |
API | REST |
.
├── android
│ ├── app
│ └── gradle
├── ios
│ ├── Pods
│ ├── <APP_NAME>
│ ├── <APP_NAME>-tvOS
│ ├── <APP_NAME>-tvOSTests
│ ├── <APP_NAME>.xcodeproj
│ ├── <APP_NAME>.xcworkspace
│ └── <APP_NAME>Tests
└── src
├── __tests__
├── assets
├── components
├── config
├── features
├── library
├── navigators
├── screens
├── scripts
├── store
├── styles
└── utils
Note: Each \src\element has it's own package.json to simplify imports without using relataive paths.
Element | Path | Notes |
---|---|---|
Tools Config | root | Build system, code quality, docs. |
Android Target | \android | Requires Android Studio |
iOS Target | \ios | Open <APP_NAME>.xcworkspace file in xCode |
Unit Tests | \src\__tests__ | Integration Jest tests. Component unit tests are co-located within component. |
Static Assets | \src\assets | Binary assets, ie images |
React Components | \src\components | React components local to app. ie Hooks, Components, Contexts, etc. |
App Config | \src\config | App local configs |
Features | \src\features | Deprecated |
Library | \src\library | Deprecated |
Navigation UX | \src\navigators | React Navigation navigators |
Screen UX | \src\screens | React Navigation screens |
NPM Scripts | \src\scripts | NPM package.json scripts |
Redux Store | \src\store | Redux store and store slices |
Style UX | \src\style | Themes, palettes, typography, element ux specs, accessablity, etc. |
Utils | \src\utils | Minimize or deprecate |
Metro JS Server and Hot Reloading