Learning React Native, Chapter 4: Components for Mobile
Analogies Between HTML and Native Components
Many of the React Native components are directly comparable to their HTML counterparts. While they are similar, they they are not interchangeable. You cannot share UI code between React on the web and React Native. The JavaScript code is shareable as long as it only contains JavaScript. You should put all your business logic in their own files to make converting your code from one to the other much easier.
The Component
In React Native, text has to be enclosed in
The Component
The Working with Touch And Gestures
React Native provides API's for using touch and gestures.Creating Basic Iterations with
Button component is a simple API, it allows the setting of color, label text, and callback functions.
Using Component
Any element that responds to a user's touch, should probably be wrapped in Using the Pan Responder Class
PanResponder is a class provided by React Native, it is not a component. Create a PanResponder object and attach it to the components render method. There are six callbacks we have to register:- onStartShouldSetPanResponder
- OnMoveShouldSetPanResponder
- onPanResponderGrant
- onPanResponderMove
- onPanResponderRelease
- onPanResponderTerminate
Choosing how to handle touch
For simple implementations,Working with Lists
ReactNative provides two API's for lists.
Using the Basic Component
The RenderItem should be a function that builds a component from one element of the data array.
Updating the Contents
We are going to build an app that displays the New York Times bestseller list with the book title, author and cover. We build several different functions, and some mock data we can use to test our app with. Integrating Real Data
This section contains the functions we need to make our API call, and get the real data from the New York Times API.
Working with
Navigation
Code that allows users to transition from one screen to another. There are several different generic and platform specific navigation components.Other Organizational Components
There are many such components. A few useful onse areLinks:
Comments
Post a Comment