Skip to content
Tutorials Center
My learning

Topics

Lesson 5 of 71 ยท Getting Started

Building Your First Screen

Compose View, Text and Image into a profile screen, pass props, style with StyleSheet.create, handle safe areas and the status bar, and use Fast Refresh.

You know the core components. Now you will combine them into a real screen: a small profile card with a photo, a name, a short bio and a row of stats. Along the way you meet the pieces every screen needs: props to make components reusable, StyleSheet.create for styles, a safe area so content does not hide behind the notch, a status bar, and Fast Refresh so you can see changes as you type.

Real and stand-in. The react-native code is read-only here. The TryIts render the same component structure to HTML inside a phone-shaped frame. A tiny converter translates React Native style names (such as paddingHorizontal) to CSS, so the picture is close to, but not identical with, a device.

Compose the screen from components

Start by splitting the screen into small components. A good first split is one component per visual chunk:

TSX
import { Image, StyleSheet, Text, View } from 'react-native';

type StatProps = { label: string; value: number };

function Stat({ label, value }: StatProps) {
  return (
    <View style={styles.stat}>
      <Text style={styles.statValue}>{value}</Text>
      <Text style={styles.statLabel}>{label}</Text>
    </View>
  );
}

type ProfileProps = { name: string; bio: string; avatar: string };

export function Profile({ name, bio, avatar }: ProfileProps) {
  return (
    <View style={styles.card}>
      <Image source={{ uri: avatar }} style={styles.avatar} />
      <Text style={styles.name}>{name}</Text>
      <Text style={styles.bio}>{bio}</Text>
      <View style={styles.statsRow}>
        <Stat label="Posts" value={42} />
        <Stat label="Followers" value={1280} />
        <Stat label="Following" value={310} />
      </View>
    </View>
  );
}

This is plain React: props flow down, and each component returns a tree. Nothing here is specific to phones except the building blocks. Notice that the Stat component takes a number and renders it inside Text; numbers are allowed as children of Text, just as strings are.

Style with StyleSheet.create

Styles are JavaScript objects. StyleSheet.create groups them and checks the property names:

TSX
const styles = StyleSheet.create({
  card: {
    alignItems: 'center',
    padding: 24,
    backgroundColor: '#ffffff',
    borderRadius: 16,
  },
  avatar: { width: 96, height: 96, borderRadius: 48 },
  name: { marginTop: 12, fontSize: 22, fontWeight: '700', color: '#0f172a' },
  bio: { marginTop: 4, fontSize: 15, color: '#475569', textAlign: 'center' },
  statsRow: { flexDirection: 'row', marginTop: 20, gap: 24 },
  stat: { alignItems: 'center' },
  statValue: { fontSize: 18, fontWeight: '700' },
  statLabel: { fontSize: 12, color: '#64748b' },
});

Remember three rules: property names are camelCase, numbers are density-independent pixels (not CSS px), and layout is Flexbox in a column unless you say flexDirection: 'row'. A full tour of styling is coming in Styling with StyleSheet and Flexbox in React Native.

Anatomy of a screen

Components Small pieces, one job each.
Props Data flows down.
StyleSheet Style objects, named once.
Flexbox Column by default.
1 / 2
A profile screen in a phone frame

Safe areas and the status bar

Modern phones have notches, camera cutouts, rounded corners and a home indicator. If your content runs to the very edge, parts of it hide under these areas. The safe area is the region that is always visible. Wrap your screens in a SafeAreaView from the react-native-safe-area-context package, which Expo includes:

TSX
import { SafeAreaView } from 'react-native-safe-area-context';
import { StatusBar } from 'expo-status-bar';

export default function Home() {
  return (
    <SafeAreaView style={{ flex: 1, backgroundColor: '#f1f5f9' }}>
      <StatusBar style="dark" />
      <Profile name="Maya Okafor" bio="Mobile developer." avatar="https://example.com/a.jpg" />
    </SafeAreaView>
  );
}

Use this package's SafeAreaView, not the one from react-native: the built-in one works only on iOS and is deprecated. If you use Expo Router with a navigator header or tab bar, the navigator usually handles the top and bottom insets for you, so check before adding padding twice. The flex: 1 on the outer view means "fill all available space", which is how a screen takes the whole display. StatusBar from expo-status-bar chooses light or dark icons so the clock and battery stay readable on your background.

Props make screens reusable

The same Profile component can render a hundred different people. Props are the only way a parent talks to a child, and in TypeScript you describe them with a type. The stand-in below renders three profiles from data, and it adds one small convenience used in most apps: a reusable AppText that sets the font and color once.

Reusable components from data

Fast Refresh

While npx expo start runs, saving a file updates the app in place, usually in under a second, and keeps the state of your components. This is Fast Refresh. If you edit a component's markup or styles, you see the change immediately. A few rules help it behave:

  • If you edit a file that exports a mix of components and other values, the whole module and its dependents reload, and state resets.
  • A syntax error shows a red error screen; fix it and the screen recovers.
  • Runtime errors show too, and can be dismissed once fixed.
  • To force a clean reload, press r in the terminal or shake the device to open the developer menu.

Treat Fast Refresh as a design tool: change a margin, look at the phone, change it again. That tight loop is one of the best parts of React Native development.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which SafeAreaView should you import for cross-platform apps?

    The built-in react-native SafeAreaView works only on iOS and is deprecated. The safe-area-context package works on both platforms.
  2. 2. What does flex: 1 on a screen's outer View do?

    flex: 1 tells the view to grow and take the available space in its parent, which is how a screen fills the display.
  3. 3. What is true about Fast Refresh?

    Fast Refresh swaps updated code into the running app. State is kept for edited components unless the module also exports non-component values.
  4. 4. Which style name is valid in React Native?

    Style properties are camelCase, and values are numbers or specific strings. There are no CSS shorthand strings with units, but paddingHorizontal and paddingVertical exist.

Summary

  • Build screens from small components; pass data down with props.
  • Style with StyleSheet.create: camelCase names, numeric dp values, Flexbox in a column by default.
  • Use SafeAreaView from react-native-safe-area-context and StatusBar from expo-status-bar so content stays visible and readable.
  • flex: 1 makes a screen fill the display.
  • Fast Refresh updates the app as you save and usually keeps state.

Next, look under the hood in How React Native Runs Your Code.