Mobile development

Stage 2 · Lesson 4 of 10

Flexbox layout

React and React Native components

Layout in uses , a set of rules for sharing space between children. It has a few defaults that differ from the web. flexDirection is , not row, and every View is a flex container.

justifyContent positions children along the main direction and alignItems across it. flex: 1 makes a child fill the remaining space, and gap adds space between children. Use position: 'absolute' for overlays such as a badge on an avatar.

Percentages work, but prefer flex so layouts adapt. Learn to predict a layout before running it, because most layout bugs are a missing flex: 1 on a parent.

Common trapcopying web and expecting row as the default direction, or grid layouts that do not exist.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • GuideFree
    Expo Documentation

    Expo

    The Expo tutorial builds a small app you run on your own phone

  • GuideFree
    React Documentation

    Meta

    "Describing the UI" and "Adding interactivity" cover the React you need

Practise

  • Use a free challenge's mobile design image as the spec for a native screen

Keep handy

Mark this stage as not done?