Created
December 11, 2016 13:37
-
-
Save anonymous/34883168b8ed274ca566d19e572bf2b1 to your computer and use it in GitHub Desktop.
React Hello World w/ JSBin // source http://jsbin.com/jagegofona
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-0.13.1.js"></script> | |
<meta charset="utf-8"> | |
<title>React Hello World w/ JSBin</title> | |
</head> | |
<body> | |
<div id="react_example"></div> | |
<script id="jsbin-javascript"> | |
'use strict'; | |
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | |
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | |
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | |
var HelloWorldComponent = (function (_React$Component) { | |
_inherits(HelloWorldComponent, _React$Component); | |
function HelloWorldComponent() { | |
_classCallCheck(this, HelloWorldComponent); | |
_get(Object.getPrototypeOf(HelloWorldComponent.prototype), 'constructor', this).call(this); | |
this.state = { name: 'default' }; | |
} | |
_createClass(HelloWorldComponent, [{ | |
key: 'render', | |
value: function render() { | |
return React.createElement( | |
'div', | |
null, | |
React.createElement( | |
'h1', | |
null, | |
'Hello ', | |
this.props.name | |
) | |
); | |
} | |
}]); | |
return HelloWorldComponent; | |
})(React.Component); | |
var SearchBar = (function (_React$Component2) { | |
_inherits(SearchBar, _React$Component2); | |
function SearchBar() { | |
_classCallCheck(this, SearchBar); | |
_get(Object.getPrototypeOf(SearchBar.prototype), 'constructor', this).call(this); | |
this.state = { term: 'default' }; | |
} | |
_createClass(SearchBar, [{ | |
key: 'render', | |
value: function render() { | |
var _this = this; | |
console.log(this.state); | |
return React.createElement( | |
'div', | |
{ id: 'search' }, | |
React.createElement(HelloWorldComponent, { name: this.state.term }), | |
React.createElement( | |
'label', | |
{ 'for': 'mysearch2' }, | |
'Enter your search string here : ' | |
), | |
React.createElement('input', { id: 'mysearch2', value: this.state.term, type: 'search', placeholder: 'search', onChange: function (event) { | |
return _this.setState({ term: event.target.value }); | |
} }) | |
); | |
} | |
}]); | |
return SearchBar; | |
})(React.Component); | |
React.render(React.createElement(SearchBar, { name: 'default' }), document.getElementById('react_example')); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//fb.me/react-0.13.1.js"><\/script> | |
<meta charset="utf-8"> | |
<title>React Hello World w/ JSBin</title> | |
</head> | |
<body> | |
<div id="react_example"></div> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript">class HelloWorldComponent extends React.Component { | |
constructor() | |
{ | |
super(); | |
this.state = {name:'default'}; | |
} | |
render() { | |
return ( | |
<div> | |
<h1>Hello {this.props.name}</h1> | |
</div> | |
); | |
} | |
} | |
class SearchBar extends React.Component{ | |
constructor() | |
{ | |
super(); | |
this.state={term:'default'}; | |
} | |
render() | |
{ | |
console.log(this.state); | |
return( | |
<div id="search"> | |
<HelloWorldComponent name={this.state.term}/> | |
<label for="mysearch2">Enter your search string here : </label> | |
<input id="mysearch2" value={this.state.term} type="search" placeholder="search" onChange={event => this.setState({term:event.target.value})}/> | |
</div> | |
); | |
} | |
} | |
React.render( | |
<SearchBar name="default"/>, | |
document.getElementById('react_example') | |
);</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
'use strict'; | |
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | |
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | |
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | |
var HelloWorldComponent = (function (_React$Component) { | |
_inherits(HelloWorldComponent, _React$Component); | |
function HelloWorldComponent() { | |
_classCallCheck(this, HelloWorldComponent); | |
_get(Object.getPrototypeOf(HelloWorldComponent.prototype), 'constructor', this).call(this); | |
this.state = { name: 'default' }; | |
} | |
_createClass(HelloWorldComponent, [{ | |
key: 'render', | |
value: function render() { | |
return React.createElement( | |
'div', | |
null, | |
React.createElement( | |
'h1', | |
null, | |
'Hello ', | |
this.props.name | |
) | |
); | |
} | |
}]); | |
return HelloWorldComponent; | |
})(React.Component); | |
var SearchBar = (function (_React$Component2) { | |
_inherits(SearchBar, _React$Component2); | |
function SearchBar() { | |
_classCallCheck(this, SearchBar); | |
_get(Object.getPrototypeOf(SearchBar.prototype), 'constructor', this).call(this); | |
this.state = { term: 'default' }; | |
} | |
_createClass(SearchBar, [{ | |
key: 'render', | |
value: function render() { | |
var _this = this; | |
console.log(this.state); | |
return React.createElement( | |
'div', | |
{ id: 'search' }, | |
React.createElement(HelloWorldComponent, { name: this.state.term }), | |
React.createElement( | |
'label', | |
{ 'for': 'mysearch2' }, | |
'Enter your search string here : ' | |
), | |
React.createElement('input', { id: 'mysearch2', value: this.state.term, type: 'search', placeholder: 'search', onChange: function (event) { | |
return _this.setState({ term: event.target.value }); | |
} }) | |
); | |
} | |
}]); | |
return SearchBar; | |
})(React.Component); | |
React.render(React.createElement(SearchBar, { name: 'default' }), document.getElementById('react_example')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment