All the necessary files to configure your development environment for a brand new React Native project.
Because a React Native project has a lot of configuration files (for both iOS/Android), it is difficult to rename the project, its dependencies, and its package names. For that reason, it is best to start a new project from scratch, and then copy over any files needed to configure the rest of the environment.
The instructions below are tightly coupled with the assumption that you have read about Setting Up A Development Environment in the React Native official docs.
Initialize a new React Native app with the command:
npx react-native init <app_name>
If your project is using TypeScript, then it is best to install with a community preferred TypeScript template:
npx react-native init <app_name> --template react-native-template-typescript
Setup dependencies for the project.
- Delete
node_modules
andyarn.lock
- Copy the
package.json
from this repo into the project (be sure to update thename
property in this file) - Run
yarn install
Copy over the environment configuration files.
tsconfig.json
: defines TypeScript compiler/configuration settingsmetro.config.js
: configuration for Facebook's Metro bundlerjest.config.js
: Jest (testing library) config.babelrc
: Babel (JSX transpiler) config. Be sure to remove/rename the existingbabel.config.js
.prettierrc
: Prettier (code formatter) config. Be sure to remove/rename the existingprettierrc.js
.eslintrc
: ESLint (code linter) config. Be sure to remove/rename the existingeslintrc.js
.prettierignore
: Defines files to not be formatted by Prettier (similar to.gitignore
)index.js
: root file for the project
If the linters/formatters are throwing red squillies even after all files have been copied over, try reloading the developer window (CTRL+SHIFT+P in VSCode)
In order to run, debug, and test a React Native app, you will need to have an emulator running. Below are instructions for each platform.
The React Native docs have a thorough guide to installing Android Studio and any emulators. Before trying to run the app, ensure the project is open in Android Studio.
You will need to have Metro Bundler running first:
yarn run start
(which is shorthand for npx react-native start
)