码迷,mamicode.com
首页 > 其他好文 > 详细

[React Fundamentals] Introduction to Properties

时间:2016-08-14 07:56:03      阅读:129      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!