React Native | Getting Started

Inhaltsverzeichnis [Anzeigen]

General Readings

Create App

Expo CLI Quickstart

Assuming that you have Node 12 LTS or greater installed, you can use npm to install the Expo CLI command line utility:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
npm install -g expo-cli
npm install -g expo-cli
npm install -g expo-cli

Then run the following commands to create a new React Native project called “GettingStarted”:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
expo init app-getting-started
cd app-getting-started
npm start # you can also use: expo start
expo init app-getting-started cd app-getting-started npm start # you can also use: expo start
expo init app-getting-started
cd app-getting-started
npm start # you can also use: expo start

React Native CLI Quickstart

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
npx react-native init app-getting-started
npx react-native init app-getting-started
npx react-native init app-getting-started

or create new project based on a template

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
npx react-native init app-getting-started--template react-native-template-typescript
npx react-native init app-getting-started--template react-native-template-typescript
npx react-native init app-getting-started--template react-native-template-typescript

Start App

Step 1: Start Metro

First, you will need to start Metro (Docs), the JavaScript bundler that ships with React Native. Metro “takes in an entry file and various options, and returns a single JavaScript file that includes all your code and its dependencies.”

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
npx react-native start
npx react-native start
npx react-native start

Then, visit the Website or the Metro Page (http://localhost:8081/)

Step 2: Start your application

Let Metro Bundler run in its own terminal. Open a new terminal inside your React Native project folder. Run the following:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# For running app on iOS
npx react-native run-ios
# For running app on Android
npx react-native run-android
# For running app on iOS npx react-native run-ios # For running app on Android npx react-native run-android
# For running app on iOS
npx react-native run-ios

# For running app on Android
npx react-native run-android