class GoodMorning extends Component{
static defaultProps = {
name: 'man'
};
render(){
return(
<View>
<Text>{this.props.name}</Text>
</View>
)
}
}
const GoodEvening = (props) => {
return(
<Text>{props.name}</Text>
)
}
var helloworld = React.createClass({
render() {
return (
<View style={styles.container}>
<GoodMorning name="haha" />
<GoodEvening name="lala" />
</View>
);
})
组件是一个class或者一个函数,class用defaultProps来访问
网友评论