Skip to content

Instantly share code, notes, and snippets.

@dawogfather
Created October 21, 2017 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dawogfather/ebfbb8aeb2acdc6aa103ded5ddcaca77 to your computer and use it in GitHub Desktop.
Save dawogfather/ebfbb8aeb2acdc6aa103ded5ddcaca77 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/vuluvik
<!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>
//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);
@dawogfather
Copy link
Author

this is the ES5 equivalent of https://egghead.io/lessons/react-owner-ownee-relationship i think...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment