React componentWillUpdate

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="js/react.js"></script>
<script src="js/react-dom.js"></script>
<script src="js/browser.min.js"></script>
</head>
<body>
<div id="example"></div> <script type="text/babel"> var MySwitch = React.createClass({
componentWillUpdate:function(props,state){
console.log(state);
},
getInitialState:function(){
return {switch:false}
},
handleClick:function(){
this.setState({switch:!this.state.switch});
},
render:function(){
return <button onClick={this.handleClick}>
{"当前状态为:"+this.state.switch}
</button>
}
})
ReactDOM.render(
<MySwitch/>,
document.getElementById('example')
) </script> </body>
</html>
上一篇:QC使用中问题点汇总


下一篇:[STemWin教程入门篇] 第一期:emWin介绍