Created
January 23, 2016 09:07
-
-
Save anonymous/4e3b3e6be7c3c1cfc74f to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/beqalo
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> | |
<script src="http://fb.me/react-with-addons-0.14.3.js"></script> | |
<script src="http://fb.me/react-dom-0.14.3.js"></script> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="root"> | |
</div> | |
<script id="jsbin-javascript"> | |
var Button = React.createClass({displayName: 'Button', | |
localHandleClick: function(){ | |
this.props.localHandleClick(this.props.increment, this.props.sign); | |
}, | |
render: function(){ | |
return (React.createElement("button", {onClick: this.localHandleClick}, this.props.sign, this.props.increment, " ")); | |
} | |
}); | |
var Results = React.createClass({displayName: 'Results', | |
render: function(){ | |
return (React.createElement("div", null, this.props.localCounter)); | |
} | |
}); | |
var Main = React.createClass({displayName: 'Main', | |
getInitialState: function(){ | |
return {counter:0} | |
}, | |
handleClick: function(increment,sign){ | |
if(sign == "-"){ | |
this.setState({counter: this.state.counter - increment}); | |
}else{ | |
this.setState({counter: this.state.counter + increment}); | |
} | |
}, | |
render: function(){ | |
return (React.createElement("div", null, | |
React.createElement(Button, {localHandleClick: this.handleClick, increment: 3, sign: "+"}), | |
React.createElement(Button, {localHandleClick: this.handleClick, increment: 100, sign: "-"}), | |
React.createElement(Button, {localHandleClick: this.handleClick, increment: 50, sign: "+"}), | |
React.createElement(Button, {localHandleClick: this.handleClick, increment: 5, sign: "-"}), | |
React.createElement(Results, {localCounter: this.state.counter}) | |
)); | |
} | |
}); | |
React.render(React.createElement(Main, null), document.getElementById("root")); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//fb.me/react-with-addons-0.14.3.js"><\/script> | |
<script src="//fb.me/react-dom-0.14.3.js"><\/script> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="root"> | |
</div> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript">var Button = React.createClass({ | |
localHandleClick: function(){ | |
this.props.localHandleClick(this.props.increment, this.props.sign); | |
}, | |
render: function(){ | |
return (<button onClick={this.localHandleClick}>{this.props.sign}{this.props.increment} </button>); | |
} | |
}); | |
var Results = React.createClass({ | |
render: function(){ | |
return (<div>{this.props.localCounter}</div>); | |
} | |
}); | |
var Main = React.createClass({ | |
getInitialState: function(){ | |
return {counter:0} | |
}, | |
handleClick: function(increment,sign){ | |
if(sign == "-"){ | |
this.setState({counter: this.state.counter - increment}); | |
}else{ | |
this.setState({counter: this.state.counter + increment}); | |
} | |
}, | |
render: function(){ | |
return (<div> | |
<Button localHandleClick = {this.handleClick} increment={3} sign={"+"} /> | |
<Button localHandleClick = {this.handleClick} increment={100} sign={"-"} /> | |
<Button localHandleClick = {this.handleClick} increment={50} sign={"+"} /> | |
<Button localHandleClick = {this.handleClick} increment={5} sign={"-"} /> | |
<Results localCounter= {this.state.counter} /> | |
</div>); | |
} | |
}); | |
React.render(<Main />, document.getElementById("root"));</script></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
var Button = React.createClass({displayName: 'Button', | |
localHandleClick: function(){ | |
this.props.localHandleClick(this.props.increment, this.props.sign); | |
}, | |
render: function(){ | |
return (React.createElement("button", {onClick: this.localHandleClick}, this.props.sign, this.props.increment, " ")); | |
} | |
}); | |
var Results = React.createClass({displayName: 'Results', | |
render: function(){ | |
return (React.createElement("div", null, this.props.localCounter)); | |
} | |
}); | |
var Main = React.createClass({displayName: 'Main', | |
getInitialState: function(){ | |
return {counter:0} | |
}, | |
handleClick: function(increment,sign){ | |
if(sign == "-"){ | |
this.setState({counter: this.state.counter - increment}); | |
}else{ | |
this.setState({counter: this.state.counter + increment}); | |
} | |
}, | |
render: function(){ | |
return (React.createElement("div", null, | |
React.createElement(Button, {localHandleClick: this.handleClick, increment: 3, sign: "+"}), | |
React.createElement(Button, {localHandleClick: this.handleClick, increment: 100, sign: "-"}), | |
React.createElement(Button, {localHandleClick: this.handleClick, increment: 50, sign: "+"}), | |
React.createElement(Button, {localHandleClick: this.handleClick, increment: 5, sign: "-"}), | |
React.createElement(Results, {localCounter: this.state.counter}) | |
)); | |
} | |
}); | |
React.render(React.createElement(Main, null), document.getElementById("root")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment