/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, {Component} from 'react';
import { AppRegistry,Text,View } from 'react-native';
class Bananas extends Component {
render() {
return(
<Text>
Hello,{ this.props.name }
</Text>
)
}
}
export default class Parent extends Component {
render() {
return (
<View>
<Bananas name="xiao"/>
</View>
)
}
}
AppRegistry.registerComponent('xiao', () => Parent);
一个js文件中可以写多个class组件,谁做父组件,谁做子组件这个看需求,根据自己而定。