made with esnextbin
Created
September 23, 2016 21:14
-
-
Save nfcampos/10f5e3b63353827d220fbe6c4bfe7c05 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains 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 --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
This file contains 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 | |
import React from 'react' | |
import ReactDOM from 'react-dom' | |
class Boo extends React.Component { | |
constructor() { | |
super() | |
this.handleKeyDown = this.handleKeyDown.bind(this) | |
this.state = {tabPressedCount: 0} | |
} | |
handleKeyDown(e) { | |
if (e.keyCode === 9) { // tab key | |
e.preventDefault() | |
this.setState({tabPressedCount: 1 + this.state.tabPressedCount}) | |
} | |
} | |
render() { | |
return <div> | |
<div>{this.state.tabPressedCount}</div> | |
<textarea onKeyDown={this.handleKeyDown} /> | |
</div> | |
} | |
} | |
ReactDOM.render(<Boo />, document.body); |
This file contains 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", | |
"dependencies": { | |
"react": "15.3.2", | |
"react-dom": "15.3.2", | |
"babel-runtime": "6.11.6" | |
} | |
} |
This file contains 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 _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); | |
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); | |
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | |
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | |
var _createClass2 = require('babel-runtime/helpers/createClass'); | |
var _createClass3 = _interopRequireDefault(_createClass2); | |
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | |
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | |
var _inherits2 = require('babel-runtime/helpers/inherits'); | |
var _inherits3 = _interopRequireDefault(_inherits2); | |
var _react = require('react'); | |
var _react2 = _interopRequireDefault(_react); | |
var _reactDom = require('react-dom'); | |
var _reactDom2 = _interopRequireDefault(_reactDom); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
// write ES2015 code and import modules from npm | |
// and then press "Execute" to run your program | |
var Boo = function (_React$Component) { | |
(0, _inherits3.default)(Boo, _React$Component); | |
function Boo() { | |
(0, _classCallCheck3.default)(this, Boo); | |
var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(Boo).call(this)); | |
_this.handleKeyDown = _this.handleKeyDown.bind(_this); | |
_this.state = { tabPressedCount: 0 }; | |
return _this; | |
} | |
(0, _createClass3.default)(Boo, [{ | |
key: 'handleKeyDown', | |
value: function handleKeyDown(e) { | |
if (e.keyCode === 9) { | |
// tab key | |
e.preventDefault(); | |
this.setState({ tabPressedCount: 1 + this.state.tabPressedCount }); | |
} | |
} | |
}, { | |
key: 'render', | |
value: function render() { | |
return _react2.default.createElement( | |
'div', | |
null, | |
_react2.default.createElement( | |
'div', | |
null, | |
this.state.tabPressedCount | |
), | |
_react2.default.createElement('textarea', { onKeyDown: this.handleKeyDown }) | |
); | |
} | |
}]); | |
return Boo; | |
}(_react2.default.Component); | |
_reactDom2.default.render(_react2.default.createElement(Boo, null), document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment