- 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.
推薦閱讀
- Mastering vRealize Operations Manager(Second Edition)
- 網絡操作系統:Windows Server 2003管理與應用
- 新手易學:系統安裝與重裝
- 開源安全運維平臺OSSIM疑難解析:入門篇
- Moodle 3.x Teaching Techniques(Third Edition)
- Java EE 8 Design Patterns and Best Practices
- 竹林蹊徑:深入淺出windows驅動開發
- OpenStack系統架構設計實戰
- 從實踐中學習Kali Linux無線網絡滲透測試
- Hands-On UX Design for Developers
- Linux基礎使用與案例
- Hands-On GPU Programming with Python and CUDA
- Raspberry Pi入門指南
- Learn OpenShift
- Gradle Effective Implementations Guide(Second Edition)