首页 > 其他 > 详细

[React Fundamentals] Introduction to Properties

时间:2016-08-14 07:53:28      阅读:256      评论:0      收藏:0      [点我收藏+]

This lesson will teach you the basics of setting properties in your React components.

 

class App extends React.Component {
  render(){
    let txt = this.props.txt
    return <h1>{txt}</h1>
  }
}

App.propTypes = {
  txt: React.PropTypes.string,
  cat: React.PropTypes.number.isRequired
}

App.defaultProps ={
  txt: ‘this is the default txt‘
}

ReactDOM.render(
  <App cat={5} />,
  document.getElementById(‘app‘)
);

 

[React Fundamentals] Introduction to Properties

原文:http://www.cnblogs.com/Answer1215/p/5769429.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!