Make sure you’ve completed the environment setup before starting this tutorial.
Create a new project
Use the React Native CLI to create a new project:Run your app
- iOS
- Android
Open a new terminal and run:This will:
- Build the native iOS app with Xcode
- Launch the iOS Simulator
- Install and run your app
Specify a device with
--simulator="iPhone 15 Pro"Understanding the project structure
Entry point: index.js
This file registers your app with React Native:index.js
AppRegistry is the JavaScript entry point for all React Native apps. It registers your root component so the native code can load and run it.
Main component: App.tsx
Your app’s root component defines the UI:App.tsx
Core components explained
SafeAreaView
Renders content within safe area boundaries, avoiding notches and system UI
View
The fundamental container component - equivalent to
div in web developmentText
Displays text - all text must be wrapped in
<Text> componentsScrollView
Scrollable container for content that exceeds screen bounds
Make your first changes
Let’s build a simple counter app to learn React Native fundamentals:Complete counter app
Here’s the full code for reference:Key concepts learned
React Native components vs. HTML
- React Native
- Web (HTML)
Styling with StyleSheet
React Native uses JavaScript objects for styling, similar to CSS-in-JS:- Property names use camelCase (
backgroundColornotbackground-color) - No units for numeric values (they’re in density-independent pixels)
- Flexbox is the default layout system
- Limited subset of CSS properties
Platform-specific code
Write code that adapts to iOS and Android:Fast Refresh in action
Fast Refresh automatically reloads your app when you save changes:Component state is preserved
Your counter value stays the same when you edit styling or add new components
Full reload when needed
Fast Refresh triggers a full reload if you edit exported components or make syntax errors
To disable Fast Refresh: shake the device → Dev Menu → “Disable Fast Refresh”
Debugging your app
Chrome DevTools
Open the developer menu and select “Debug”:- iOS Simulator
- Android Emulator
Press
Cmd + D or Device → ShakeConsole logs
Use standard console methods:- Metro bundler terminal
- Chrome DevTools console
- Xcode console (iOS)
- Android Logcat (Android)
Next steps
Run on device
Test your app on a physical iPhone or Android device
Core components
Learn about built-in components like FlatList, Image, and TextInput
Navigation
Add multi-screen navigation with React Navigation
Networking
Fetch data from APIs with fetch() and handle responses
Common issues
Red screen errors
Red screen errors
Red screens indicate JavaScript errors. Read the error message carefully - it usually points to the exact line causing the issue.Common causes:
- Syntax errors
- Undefined variables
- Incorrect imports
Yellow box warnings
Yellow box warnings
Yellow boxes show warnings that don’t crash the app but should be addressed:
- Deprecated API usage
- Performance warnings
- Accessibility issues
Metro bundler issues
Metro bundler issues
If Metro isn’t connecting:
Build failures
Build failures
iOS: Clean build folder in Xcode (Shift + Cmd + K)Android: Clean Gradle cache