The first explanation AppRegistry
is JS running all react native applications what is the portal?
1. When we initialize a react native project, the default index.ios.js/index.ios.js content is this
(Here we simplify the code)
Import React, {Component} from ' React '; import { appregistry, StyleSheet, Text, View} from ' React-native '; class Allen extends Component { render () { return ( <view style={styles.container}> <text style={styles.welcome}> Welcome to React native! </Text> </View> );} } Const STYLES = stylesheet.create ({ container: { flex:1, justifycontent: ' Center ', alignitems: ' Center ', backgroundcolor: ' #F5FCFF ', },}); Appregistry.registercomponent (' Allen ', () = Allen);
In this code, the system automatically creates a component called Allen, and the component is displayed by the registration function of the Appregistry API.
This "Allen" with double quotes means that Allen, behind the name of the app, represents the name of the component to be displayed, so we can create a xxx.js file (a file in React-native is also a component) Then we can register this component here to show what this JS is presenting
Import React, {Component} from ' React '; import { appregistry, StyleSheet, Text, View} from ' React-native '; import NextPage from './nextpage ' appregistry.registercomponent (' Allen ', () = NextPage); Registering components
Import React, {Component} from ' React ';//importing React Build Import {//Required build Imports Appregistry, StyleSheet, Text, View, Navigator, touchablehighlight} from ' react-native '; export default class Hellopage extends Component { // Note: The registered component is only registered once and the component name is irrelevant and the file component name is about constructor (props) { super (props) } render () { const { Navigator} = This.props; Return ( <view style={{padding:50,borderwidth:1,}}> <text Style={{fontsize:50,}}>sds ' d ' f ' d ' sds</text> </View> ) }}
RN's first API-----Registration component Appregistry