CHAPTER 05
Beginner
Creating Your First React Native App
Updated: May 16, 2026
5 min read
# CHAPTER 5
Creating Your First React Native App
1. Introduction
The theory is over. It is time to build. When you generate a new React Native project using Expo, it creates a fully functioning "Hello World" application instantly. However, looking at the generated files for the first time can be overwhelming. Where does the app actually start? How do you change the text on the screen? How do you see those changes on your phone? In this chapter, we will master Creating Your First React Native App. We will dissect the Expo project file structure, modify the rootApp.js file, and experience the magic of React Native's Hot Reloading system.
2. Learning Objectives
By the end of this chapter, you will be able to:- Identify the core files and folders in an Expo project structure.
-
Understand the role of
App.jsas the root entry point.
- Modify the default code to display custom text.
- Run the Metro Bundler and view the app on a physical device.
- Utilize Fast Refresh to see code changes instantly.
3. The Expo Project File Structure
Open the folder you created in Chapter 2 (MyFirstApp) inside Visual Studio Code. You will see several files:
-
nodemodules/: This massive folder contains all the third-party JavaScript libraries React Native needs to run. Never modify files here.
-
package.json: The command center of your app. It lists your app's name, version, and the names of all the packages installed innodemodules.
-
app.json: The Expo configuration file. This is where you configure the app's icon, splash screen color, and final native package names (e.g.,com.yourcompany.app).
-
App.js: The heart of your application. This is the very first file that runs when your app launches.
4. Dissecting App.js
Open App.js. Let's break down the default code line-by-line:
javascript
5. Running the App (Metro Bundler)
To see this code turn into a real app:-
1.
Open the integrated terminal in VS Code (
Ctrl + ~orCmd + ~).
-
2.
Type
npx expo startand press Enter.
- 3. This launches the Metro Bundler. Metro is a local web server running on your computer. Its job is to take your JavaScript code, bundle it into one massive file, and stream it to your phone over Wi-Fi.
-
4.
Scan the massive QR code with the Expo Go app on your physical phone (or press
ato launch your Android emulator).
6. The Magic of Fast Refresh
Once the app loads on your phone, look at your computer screen.-
1.
In
App.js, change<Text>Open up App.js...</Text>to<Text>Hello React Native! I built this!</Text>.
-
2.
Press Save (
Ctrl + SorCmd + S).
- 3. Look at your phone. Instantly, the text on your phone updates.
7. Debugging Basics
If you make a typo (e.g., you type<Txt> instead of <Text>), the app will crash and display a massive red error screen on your phone.
Do not panic.
- 1. Read the red screen. It will tell you exactly what went wrong: *Can't find variable: Txt*.
- 2. Look at your VS Code terminal. It will tell you the exact file and line number where the error occurred.
- 3. Fix the typo, hit Save, and the red screen will instantly disappear!
8. Visual Learning: The App Ecosystem
txt
9. Common Mistakes
-
Writing text directly inside a View: If you write
<View>Hello World</View>, your app will instantly crash with an error. In web development, a<div>can hold text directly. In React Native, a<View>CANNOT hold text. All text strings MUST be wrapped strictly inside a<Text>component!
10. Best Practices
-
Console Logging: The easiest way to debug logic is using
console.log("Button clicked!");. But where does this print? It does NOT print on the phone screen. It prints in the VS Code terminal window where the Metro Bundler is running!
11. Mini Project: Customize the Welcome Screen
Objective: Personalize your very first application.-
1.
Ensure your app is running on your phone via
npx expo start.
-
2.
Open
App.js.
-
3.
Change the
<Text>to say "Welcome to my very first Mobile App!".
-
4.
Go down to the
stylesobject. ChangebackgroundColor: '#fff'(White) tobackgroundColor: 'dodgerblue'.
- 5. Hit Save. Watch your phone instantly transform into a blue welcome screen. Congratulations, you are officially a mobile app developer!
12. Practice Exercises
- 1. What file is considered the "Command Center" of a Node/Expo project, holding the list of installed third-party libraries?
-
2.
If you change a line of code in
App.jsand hit save, what feature automatically updates the UI on your phone without requiring a full recompilation?
13. MCQs with Answers
Question 1
What is the primary role of the Metro Bundler in a React Native development workflow?
Question 2
Which of the following code snippets will successfully render the word "Hello" on a React Native mobile screen without crashing?
14. Interview Questions
-
Q: Explain the purpose of the
App.jsfile in a React Native Expo project. How does it relate to the component tree?
- Q: Contrast the developer experience of React Native's "Fast Refresh" with traditional native Android/iOS compilation. Why is Fast Refresh a major selling point for development teams?
- Q: Describe how you would troubleshoot a red "ReferenceError" screen appearing on your physical device during development.
15. FAQs
Q: I hit save, but my phone didn't update. Why? A: Sometimes the Wi-Fi connection hiccups. In the Expo Go app, you can shake your physical phone to open the Developer Menu, and tap "Reload" to force the app to fetch the latest code from your computer.16. Summary
In Chapter 5, we moved from theory to practice and launched our very first mobile application. We explored the Expo project architecture, identifyingpackage.json as our dependency manager and App.js as the root component. We executed npx expo start to ignite the Metro Bundler, securely linking our computer's code to our physical smartphone over Wi-Fi. Finally, we utilized Fast Refresh to instantly view our UI changes, experiencing the unparalleled development speed of the React Native ecosystem.