By the end of this lesson, you will be able to:
ℹ️ Info Definition: React Native is a framework that lets you build mobile apps using JavaScript and React, allowing you to create apps for both iOS and Android from a single codebase.
Mobile apps are everywhere! Every successful business today needs a mobile presence. But traditional app development used to take months or even years. With modern AI-powered tools and frameworks like React Native, you can now build and ship apps in record time.
React Native is perfect for beginners and incredibly powerful for professionals:
Feature | React Native | Traditional Native |
---|---|---|
Development Time | 1 codebase for both platforms | 2 separate codebases |
Learning Curve | Learn once, build everywhere | Learn iOS + Android separately |
Hot Reload | See changes instantly | Slow compile times |
Community | Massive ecosystem | Platform-specific |
💡 Fun Fact: Facebook, Instagram, Tesla, and thousands of other apps are built with React Native!
🤖 AI-Powered Development We'll use AI tools throughout this lesson to write code faster, debug issues, and learn best practices. This is how modern developers work!
First, let's set up your development environment. Use these commands:
# Install Node.js (if not already installed)
# Download from https://nodejs.org/
# Install Expo CLI globally
npm install -g expo-cli
# Verify installation
expo --version
# Create a new app with Expo
expo init MyFirstApp
# Choose the "blank" template
# Navigate to your app directory
cd MyFirstApp
# Start the development server
expo start
📝 AI Tip Ask your AI assistant: "Explain what each of these commands does and why we need them for React Native development."
Your new React Native app has this structure:
MyFirstApp/
├── App.js # Main app component
├── package.json # Dependencies and scripts
├── app.json # Expo configuration
├── assets/ # Images, fonts, etc.
└── node_modules/ # Installed packages
Let's build a simple "Hello World" app that does something interesting:
import React, { useState } from 'react';
import { StyleSheet, Text, View, TouchableOpacity, Alert } from 'react-native';
export default function App() {
const [count, setCount] = useState(0);
const [message, setMessage] = useState('Welcome to my first app!');
const handlePress = () => {
const newCount = count + 1;
setCount(newCount);
if (newCount === 10) {
Alert.alert('Congratulations!', 'You clicked 10 times! 🎉');
setMessage('You did it! This is your first interactive app!');
} else if (newCount === 5) {
setMessage('Halfway there! Keep clicking!');
} else {
setMessage(`You've clicked ${newCount} times!`);
}
};
return (
<View style={styles.container}>
<Text style={styles.title}>My First App</Text>
<Text style={styles.message}>{message}</Text>
<TouchableOpacity style={styles.button} onPress={handlePress}>
<Text style={styles.buttonText}>
Tap Me! ({count})
</Text>
</TouchableOpacity>
<Text style={styles.subtitle}>
Built in 60 minutes with React Native! 📱
</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#4A90E2',
alignItems: 'center',
justifyContent: 'center',
padding: 20,
},
title: {
fontSize: 32,
fontWeight: 'bold',
color: 'white',
marginBottom: 20,
textAlign: 'center',
},
message: {
fontSize: 18,
color: 'white',
marginBottom: 30,
textAlign: 'center',
paddingHorizontal: 20,
},
button: {
backgroundColor: '#FF6B6B',
paddingHorizontal: 30,
paddingVertical: 15,
borderRadius: 25,
marginBottom: 30,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.3,
shadowRadius: 4,
elevation: 5,
},
buttonText: {
color: 'white',
fontSize: 20,
fontWeight: 'bold',
},
subtitle: {
fontSize: 16,
color: 'white',
opacity: 0.8,
},
});
🎨 What This App Does:
- Displays a welcome message
- Has an interactive button that counts taps
- Changes messages at 5 and 10 clicks
- Shows a congratulations alert at 10 clicks
- Uses modern styling with shadows and colors
expo start
Use AI to help you customize your app:
AI Prompts to try:
In just 60 minutes, you've:
Your app development journey has just begun! Here's what you can explore next:
In this lesson, you learned:
Code with AI: Try extending your app with these features.
Prompts to try:
Don't be afraid to experiment! AI can help you understand any code it generates and explain how to modify it further.