Skip to content

Instantly share code, notes, and snippets.

@conorhastings
Created May 30, 2017 19:11
Show Gist options
  • Save conorhastings/8847a06e49c77cf6d1139aa389b90ebc to your computer and use it in GitHub Desktop.
Save conorhastings/8847a06e49c77cf6d1139aa389b90ebc to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<div id='app'></div>
</body>
</html>
import React, { Component } from 'react';
import { render } from 'react-dom';
class Test extends Component {
constructor() {
super();
this.x = "hi";
}
componentDidMount() {
setTimeout(() => {
this.x="bye"
console.log(this.render);
this.render();
},1000)
}
render() {
console.log("calling");
return <span>{this.x}</span>;
}
}
render(<Test /> , document.getElementById('app'))
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"react": "15.4.2",
"react-dom": "15.4.2",
"babel-runtime": "6.22.0"
}
}
'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');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Test = function (_Component) {
(0, _inherits3.default)(Test, _Component);
function Test() {
(0, _classCallCheck3.default)(this, Test);
var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(Test).call(this));
_this.x = "hi";
return _this;
}
(0, _createClass3.default)(Test, [{
key: 'componentDidMount',
value: function componentDidMount() {
var _this2 = this;
setTimeout(function () {
_this2.x = "bye";
console.log(_this2.render);
_this2.render();
}, 1000);
}
}, {
key: 'render',
value: function render() {
console.log("calling");
return _react2.default.createElement(
'span',
null,
this.x
);
}
}]);
return Test;
}(_react.Component);
(0, _reactDom.render)(_react2.default.createElement(Test, null), document.getElementById('app'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment