Your first Expo app
You'll learn to read a React Native screen and change it in Expo, right in your browser.
Watch & read
Start with the required ones. The others are there when you need them.
Explanation
React Native is React for phones. You still write components, props and state. The difference is what you
return: instead of <div> and <p>, you use phone building blocks like <View> (a box) and <Text>
(any words on screen).
Expo is the toolkit that runs your code on a phone without installing Android Studio. Expo Snack runs it in the browser, and the Expo Go app runs it on your own phone when you scan a QR code. Expo Go supports only certain Expo versions; if it says the project is too new, pick an older SDK in Snack's menu at the bottom, or ask Mamun.
Styling looks like CSS but is written as JavaScript objects, and layout uses flexbox, the same flexbox you learned in Phase 1.
Code tour
Click a line number with a ring to read the note for that line.
Practice
Short drills. Take your time and read the code before you answer.
1export default function App() {2 const [count, setCount] = useState(1);3 return (4 <View>5 <Pressable onPress={() => setCount(count + 1)}>6 <Text>Tapped {count} times</Text>7 </Pressable>8 </View>9 );10}11// The app opens. You tap the words twice.
1import { useState } from "react";2import { Pressable, StyleSheet, Text, View } from "react-native";34export default function App() {5 const [count, setCount] = useState(0);6 return (
Runs in the browser. Choose “My Device” in Snack to try it on your phone with Expo Go.
Quick check
3 questions. Each one explains itself after you answer.
- 1 / 3In React Native, which component shows words on screen?
- 2 / 3How do you run your Snack on your own phone?
- 3 / 3You have
const styles = StyleSheet.create({ title: { fontSize: 28 } }). How do you make a<Text>use it?