- React Native Blueprints
- Emilio Rodriguez Martinez
- 153字
- 2021-07-02 15:20:00
Putting it all together
We have all the pieces to build our AddProduct screen, so let's take a look at the general structure of this component:
import React from 'react';
import prompt from 'react-native-prompt-android';
import { AsyncStorage } from 'react-native';
import {
...
} from 'native-base';
export default class AddProduct extends React.Component {
static navigationOptions = {
title: 'Add a product'
};
constructor(props) {
...
}
async componentWillMount() {
...
}
async addNewProduct(name) {
...
}
/*** User Actions Handlers ***/
_handleProductPress(product) {
...
}
_handleAddProductPress() {
...
}
async _handleRemovePress(product) {
...
}
/*** Render ***/
render() {
....
}
}
We have a very similar structure to the one we built for ShoppingList : the navigatorOptions constructor building the initial state, user action handlers, and a render method. In this case, we added a couple of async methods as a convenient way to deal with AsyncStorage.
推薦閱讀
- Linux設備驅動開發詳解(第2版)
- Windows Server 2019 Cookbook
- UNIX操作系統設計
- Hands-On DevOps with Vagrant
- SOA實踐者說
- Haskell Financial Data Modeling and Predictive Analytics
- WindowsServer2012Hyper-V虛擬化部署與管理指南
- 移動應用UI設計模式(第2版)
- 8051軟核處理器設計實戰
- Linux內核設計的藝術:圖解Linux操作系統架構設計與實現原理
- Hands-On UX Design for Developers
- Windows 8實戰從入門到精通(超值版)
- 應急指揮信息系統設計
- 計算機應用基礎(Windows 7+Office 2010)
- Docker容器技術與運維