Skip to Content
Learning React Native, 2nd Edition
book

Learning React Native, 2nd Edition

by Bonnie Eisenman
October 2017
Beginner
242 pages
4h 54m
English
O'Reilly Media, Inc.
Content preview from Learning React Native, 2nd Edition

Chapter 4. Components for Mobile

In Chapter 3, we built a simple weather app. In doing so, we touched upon the basics of building interfaces with React Native. In this chapter, we will take a closer look at the mobile-based components used for React Native, and how they compare to basic HTML elements. Mobile interfaces are based on different primitive UI elements than web pages, and thus we need to use different components.

This chapter starts with a more detailed overview of the most basic components: <View>, <Image>, and <Text>. Then, we will discuss how touch and gestures factor into React Native components, and how to handle touch events. Next, we will cover higher-level components, such as the tab bars, navigators, and lists, which allow you to combine other views into standard mobile interface patterns.

Analogies Between HTML Elements and Native Components

When developing for the web, we make use of a variety of basic HTML elements. These include <div>, <span>, and <img>, as well as organizational elements such as <ol>, <ul>, and <table>. (We could include a consideration of elements such as <audio>, <svg>, <canvas>, and so on, but we’ll ignore them for now.)

When dealing with React Native, we don’t use these HTML elements, but we use a variety of components that are nearly analogous to them (Table 4-1).

Table 4-1. Analogous HTML and Native components
HTML React Native

div

<View>

img

<Image>

span, p

<Text>

ul/ol, li

<FlatList>, child items

Although these ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning React Native

Learning React Native

Bonnie Eisenman
React and React Native - Fourth Edition

React and React Native - Fourth Edition

Adam Boduch, Roy Derks, Mikhail Sakhniuk
Learning React, 2nd Edition

Learning React, 2nd Edition

Alex Banks, Eve Porcello

Publisher Resources

ISBN: 9781491989135Errata Page