React-native Demo (4)-New project

Source: Internet
Author: User
Tags require
Source Code
/** * Sample React Native App * https://github.com/facebook/react-native */' use strict ';
var React = require (' react-native ');

var {appregistry, StyleSheet, Text, View,} = React;
        var HelloWorld = React.createclass ({render:function ()} {return (<view style={styles.container}>
        <text style={styles.welcome}> Welcome to React native! </Text> <text style={styles.instructions}> to get started, edit Index.ios.js </te xt> <text style={styles.instructions}> Press cmd+r to reload,{' \ n '} cmd+d or shake fo
  R Dev Menu </Text> </View>);

}
}); var styles = stylesheet.create ({container: {flex:1, justifycontent: ' Center ', Alignitems: ' Center ', b Ackgroundcolor: ' #F5FCFF ',}, welcome: {fontsize:20, textAlign: ' Center ', Margin:10,}, instruction S: {textAlign: ' center ', Color: ' #333333 ', Marginbottom:5,},}); Appregistry.registercomponent (' Hellowrold ', () = HelloWorld);
problem

Appregistry.registercomponent (' Hellowrold ', () = HelloWorld); The first parameter of the RegisterComponent method Hellowrold parameter must be the same as the project name, Otherwise you will get an error.

Summary

New project in 5 steps: Introduction of React-native

var React = require (' react-native ');
Defining Components
var {
  appregistry,
  StyleSheet,
  Text,
  View,
} = React;
Defining interface Controls
var HelloWorld = React.createclass ({});
Defining Control Styles
var styles = Stylesheet.create ({});
registering the interface for the project
Appregistry.registercomponent (' Project name ', () = interface);
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.