Created
October 21, 2017 02:12
-
-
Save dawogfather/ebfbb8aeb2acdc6aa103ded5ddcaca77 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/vuluvik
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"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="http://fb.me/react-with-addons-0.13.1.js"></script> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
//import React from 'react'; | |
var App = React.createClass({displayName: 'App', | |
getInitialState() { | |
return { txt: 'this is initial state' }; | |
}, | |
update: function(e){ | |
this.setState({txt: e.target.value}); | |
}, | |
render: function(){ | |
return ( | |
React.createElement("div", null, | |
React.createElement("h1", null, this.state.txt), | |
React.createElement(Widget, {update: this.update.bind(this)}) | |
) | |
) | |
} | |
}); | |
var Widget = React.createClass({displayName: 'Widget', | |
render: function(){ | |
return ( | |
React.createElement("input", {type: "text", onChange: this.props.update}) | |
) | |
} | |
}); | |
React.render(React.createElement(App, null), document.body); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="//fb.me/react-with-addons-0.13.1.js"><\/script> | |
</head> | |
<body> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript">//import React from 'react'; | |
var App = React.createClass({ | |
getInitialState() { | |
return { txt: 'this is initial state' }; | |
}, | |
update: function(e){ | |
this.setState({txt: e.target.value}); | |
}, | |
render: function(){ | |
return ( | |
<div> | |
<h1>{this.state.txt}</h1> | |
<Widget update={this.update.bind(this)}/> | |
</div> | |
) | |
} | |
}); | |
var Widget = React.createClass({ | |
render: function(){ | |
return ( | |
<input type="text" onChange={this.props.update} /> | |
) | |
} | |
}); | |
React.render(<App/>, document.body); | |
</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
//import React from 'react'; | |
var App = React.createClass({displayName: 'App', | |
getInitialState() { | |
return { txt: 'this is initial state' }; | |
}, | |
update: function(e){ | |
this.setState({txt: e.target.value}); | |
}, | |
render: function(){ | |
return ( | |
React.createElement("div", null, | |
React.createElement("h1", null, this.state.txt), | |
React.createElement(Widget, {update: this.update.bind(this)}) | |
) | |
) | |
} | |
}); | |
var Widget = React.createClass({displayName: 'Widget', | |
render: function(){ | |
return ( | |
React.createElement("input", {type: "text", onChange: this.props.update}) | |
) | |
} | |
}); | |
React.render(React.createElement(App, null), document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is the ES5 equivalent of https://egghead.io/lessons/react-owner-ownee-relationship i think...