React Native Quick Start understanding props and state

Source: Internet
Author: User

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:

    1. The so-called props, is the property transfer, and is one-way.
    2. When you have many properties, you can pass an object with the syntax {... xx}, which is a new feature of ES6.
    3. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.