官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 霍城县| 湘潭市| 石泉县| 益阳市| 万盛区| 阜康市| 英超| 红河县| 镇安县| 中方县| 宜良县| 郑州市| 苏州市| 沙河市| 虞城县| 上蔡县| 额济纳旗| 阿坝| 南平市| 前郭尔| 醴陵市| 文安县| 盐亭县| 高平市| 甘德县| 淅川县| 凤翔县| 长兴县| 星子县| 武安市| 分宜县| 中牟县| 湘阴县| 长武县| 紫阳县| 元江| 红桥区| 高雄市| 西丰县| 巨鹿县| 特克斯县|