Now react Native (hereafter referred to as RN) more and more fire, I also want to devote to study. For a front end, it is still a bit difficult. Because I think this is a field of app development, nature is different. When writing this article, the RN version is 0.21.0. We immediately enter into today's study with code.
' 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}}/> ); }}
Brief analysis:
- The so-called props, is the property transfer, and is one-way.
- When you have many properties, you can pass an object with the syntax {... xx}, which is a new feature of ES6.
- React a state to maintain the status, and the DOM is updated when it has changed.
I'll see you again today.
React Native Quick Start understanding props and state