- 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系統(tǒng)文件安全實戰(zhàn)全攻略
- Google系統(tǒng)架構(gòu)解密:構(gòu)建安全可靠的系統(tǒng)
- Ansible權威指南
- Linux網(wǎng)絡操作系統(tǒng)與實訓(第三版)
- RESS Essentials
- 巧學活用Windows 7
- Windows Server 2012網(wǎng)絡操作系統(tǒng)項目教程(第4版)
- Linux服務器配置與管理
- Docker容器技術與應用
- Linux內(nèi)核分析及應用
- Linux系統(tǒng)安全:縱深防御、安全掃描與入侵檢測
- Serverless Architectures with Kubernetes
- 電子商務系統(tǒng)建設與管理
- C++ Reactive Programming
- STM32庫開發(fā)實戰(zhàn)指南:基于STM32F103(第2版)