made with esnextbin
Created
August 25, 2016 03:09
-
-
Save parvezk/f8f9a17af9cc5378336142168281a3e2 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react-dom.js"></script> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
<h1>React Sketch</h1> | |
<div id="sketch"></div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// write ES2015 code and import modules from npm | |
// and then press "Execute" to run your program | |
var Sketch = React.createClass({ | |
getInitialState: function() { | |
return {x: 50, y: 50}; | |
}, | |
handleMouseMove: function(event) { | |
this.setState({ | |
x: event.clientX, | |
y: event.clientY | |
}); | |
}, | |
render: function() { | |
return ( | |
<svg width="640" height="480" onMouseMove={this.handleMouseMove}> | |
<circle cx={this.state.x} cy={this.state.y} r="40" | |
stroke="black" fill="white"/> | |
</svg> | |
); | |
} | |
}); | |
ReactDOM.render( | |
<Sketch/>, | |
document.getElementById('sketch') | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
// write ES2015 code and import modules from npm | |
// and then press "Execute" to run your program | |
var Sketch = React.createClass({ | |
displayName: "Sketch", | |
getInitialState: function getInitialState() { | |
return { x: 50, y: 50 }; | |
}, | |
handleMouseMove: function handleMouseMove(event) { | |
this.setState({ | |
x: event.clientX, | |
y: event.clientY | |
}); | |
}, | |
render: function render() { | |
return React.createElement( | |
"svg", | |
{ width: "640", height: "480", onMouseMove: this.handleMouseMove }, | |
React.createElement("circle", { cx: this.state.x, cy: this.state.y, r: "40", | |
stroke: "black", fill: "white" }) | |
); | |
} | |
}); | |
ReactDOM.render(React.createElement(Sketch, null), document.getElementById('sketch')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment