layout: post
what is REACT?
jsx compiler turn jsx to js
var h1 = <h1>hello world</h>
ReactDOM.render()
ReactDOM.createElement()
every component must come from a component class
constructor
render
实例代码
class Tmp extends Component{
constructor(props){
super(props)
this.state = {somekey:true
}
// 自定义函数
handleClick(e) = {
//这里不能直接访问this,原因是
// React components using ES6 classes no longer autobind this to non React methods. In your constructor, add:
// this.onChange = this.onChange.bind(this)
}
render()
{
return <h1 onClick={this.handleClick}>hello</h1>
}