2 Components

1.MyComponent.js

  1. //define component
  2. class MyComponent extends React.Component {
  3. render() {
  4. return <Text>My component!</Text>;
  5. }
  6. }
  7. //export component
  8. export default MyComponent;

2.Main.js

  1. //import component
  2. import MyComponent from './MyComponent';
  3. class Main extends React.Component {
  4. render() {
  5. //use component
  6. return <MyComponent>;
  7. }
  8. }

3.AppRegistry

  1. AppRegistry.registerComponent('MyApp', () => Main);

原文: https://unbug.gitbooks.io/react-native-training/content/2_components.html