眼下React Native(之后简称RN)愈来愈火,我也要投入到学习当中。对于一个前端来讲,仍是有些难度。由于本人以为这是一个App开发的领域,天然是不一样。编写本文的时候,RN的版本为0.21.0。咱们立刻以代码进入今天的学习。前端
'use strict'; import React, { AppRegistry, Component, StyleSheet, Text, View } from 'react-native'; class Hello extends Component { render() { return ( <View> <Text>{ this.props.title}</Text> <Text>{ this.props.text}</Text> </View> ); } } class HelloComponent extends React.Component{ constructor (props) { super(props); this.state = { appendText: '' }; } _setText() {
this.setState({appendText: ' Native!'}); } render() { return ( <View> <Text onPress={this._setText.bind(this)}> {this.props.text + this.state.appendText} </Text> </View> ); } } class learn01 extends Component { render() { const pros = { text: 'hi', title: 'title' } return ( <View> <View style={{height:30}} /> <Hello {...pros} /> <HelloComponent text="React"/> </View> ); } }
简要分析:react
今天到此为止,下次见。es6