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

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.

主站蜘蛛池模板: 宜丰县| 临漳县| 睢宁县| 洪泽县| 正安县| 察隅县| 吴川市| 景洪市| 襄垣县| 广德县| 武宁县| 惠安县| 广昌县| 通州市| 密云县| 海林市| 舒城县| 华安县| 宝清县| 鸡西市| 桦南县| 锡林浩特市| 贡嘎县| 安陆市| 上饶县| 裕民县| 德钦县| 海丰县| 新乡县| 磐石市| 象州县| 漠河县| 盐亭县| 婺源县| 蒲城县| 合肥市| 东安县| 五华县| 久治县| 海阳市| 绵阳市|