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);