<!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 EventComponent = React.createClass({
getInitialState:function(){
return {color:'#ffffff'}
},
handleWheel:function(){
console.log(' in handleWheel');
var newColor = this.getRandomColor();
this.setState({color:newColor});
},
getRandomColor:function(){
var r = Math.floor(Math.random()*256);
var g = Math.floor(Math.random()*256);
var b = Math.floor(Math.random()*256);
var R = r.toString(16);
var G = g.toString(16);
var B = b.toString(16);
return "#"+R+G+B;
},
render:function(){
return <div onWheel={this.handleWheel}
style={{backgroundColor:this.state.color}}>
Hello Event & State
</div>
}
})
ReactDOM.render(
<EventComponent/>,
document.getElementById('example')
)
</script>
</body>
</html>