React Native Dev Prep
Nov 18, 2023
SoCity Data Collector - Getting Started #
Note: Make sure you have completed the React Native - Environment Setup instructions till “Creating a new application” step, before proceeding.
Step 1: Set up your environment #
- Prerequisites:
- Node.js: Required for running the JavaScript backend.
- React Native CLI: For React Native commands.
- nvm (Node Version Manager): For managing and using different Node.js versions.
- Yarn: Fast, reliable, and secure dependency management.
- For iOS: Xcode and CocoaPods.
- For Android: Android Studio with the necessary SDKs.
-
Align Node Version:
-
Ensure you are using the correct Node.js version for this project:
nvm use -
If the correct version is not installed,
nvmwill prompt you to install it.
-
-
Install Dependencies:
-
Install project dependencies:
yarn install
-
Step 2: Start your Application #
Let Metro Bundler run in its own terminal. Open a new terminal from the root of your React Native project. Run the following command to start your Android or iOS app:
For Android #
yarn android
For iOS #
yarn ios
Step 3: Modifying your App #
Now that you have successfully run the app, let’s modify it.
-
Open
App.tsxin your text editor of choice and edit some lines. -
For Android: Press the R key twice or select “Reload” from the Developer Menu (Ctrl + M (on Window and Linux) or Cmd ⌘ + M (on macOS)) to see your changes!
For iOS: Hit Cmd ⌘ + R in your iOS Simulator to reload the app and see your changes!
Project Structure #
Understanding the structure of this React Native project is essential for efficient navigation and development. Here’s a brief overview of the main components:
App.js: Main component and the entry point for the app’s UI.README.md: Provides an overview and documentation of the project.app.json: Configuration file with metadata like name and version.ios/: Contains iOS-specific code, including Xcode project files.android/: Contains Android-specific code like Gradle files and AndroidManifest.node_modules/: Stores all npm dependencies required for the project.vendor/: Optional directory for third-party dependencies not managed by npm.Gemfile&Gemfile.lock: Manage Ruby dependencies, mainly for iOS development tools.__tests__/: Holds the test files for unit or integration testing.babel.config.js: Configuration for Babel to set up JavaScript transformation presets and plugins.jest.config.js: Configuration file for Jest, the framework used for testing JavaScript.package.json: Lists all dependencies and contains various configurations and scripts.yarn.lock: Ensures consistent installation of node modules across different environments.index.js: The application’s entry point, registering the app component fromApp.js.metro.config.js: Configuration for Metro, the JavaScript bundler used in React Native.src/: Directory for the source code of the project, including components, screens, and other JavaScript/React Native files.
Learn More #
To learn more about React Native, take a look at the following resources:
-
React Native Website - learn more about React Native.
-
Getting Started - an overview of React Native and how setup your environment.
-
Learn the Basics - a guided tour of the React Native basics.
-
Blog - read the latest official React Native Blog posts.
-
@facebook/react-native- the Open Source; GitHub repository for React Native.