React的点点滴滴
2016-05-17 本文已影响39人
Jetsly
[索引]
[1.无属性组件]
[2.有属性组件]
[3.组件的静态对象和属性]
1.无属性组件
export const ISource=()=><div>ISource</div>
等同于
export export default class ISource extends React.Component {
render() {
return <div>ISource</div>;
}
}
2.有属性组件
export const MenuItem=(name, click)=><div onClick={click}>{name}</div>
等同于
export export default class MenuItem extends React.Component {
render() {
return <div onClick={this.props.click}>{this.props.name}</div>;
}
}
3.组件的静态对象和属性
export default class Compt extends React.Component{
static displayName = 'Compt';
static defaultProps ={
name:'aaaa'
}
static propTypes = {
name: React.PropTypes.string,
}
state={
name:this.props.name
}
}
待续....