- React Native Blueprints
- Emilio Rodriguez Martinez
- 169字
- 2021-07-02 15:19:59
Putting it all together
Let's see how the whole component's structure would look like when putting all the methods together:
/*** ShoppingList.js ***/
import React from 'react';
import { Alert } from 'react-native';
import { ... } from 'native-base';
export default class ShoppingList extends React.Component {
static navigationOptions = {
title: 'My Groceries List'
};
constructor(props) {
...
}
/*** User Actions Handlers ***/
_handleProductPress(product) {
...
}
_handleAddProductPress() {
...
}
_handleClearPress() {
...
}
/*** Render ***/
render() {
...
}
}
The structure of a React Native component is very similar to a normal React component. We need to import React itself and then some components to build up our screen. We also have several event handlers (which we have prefixed with an underscore as a mere convention) and finally a render method to display our components using standard JSX.
The only difference with a React web app is the fact that we are using React Native UI components instead of DOM components.
推薦閱讀
- Linux運維之道(第3版)
- UNIX操作系統設計
- VMware Horizon View 6 Desktop Virtualization Cookbook
- Ganglia系統監控
- 構建可擴展分布式系統:方法與實踐
- 注冊表應用完全DIY
- Linux內核設計的藝術:圖解Linux操作系統架構設計與實現原理
- Windows 10從新手到高手
- Learning BeagleBone
- μC/OS-III內核實現與應用開發實戰指南:基于STM32
- Agile IT Security Implementation Methodology
- Linux內核分析及應用
- 鴻蒙HarmonyOS應用開發入門
- Responsive Web Design with AngularJS
- Linux網絡操作系統項目教程(RHEL 6.4/CentOS 6.4)(第2版)