Skip to content

Instantly share code, notes, and snippets.

@ALF-er
Created April 13, 2016 20:34
Show Gist options
  • Save ALF-er/8d438672137e12110155e8d66424c0b2 to your computer and use it in GitHub Desktop.
Save ALF-er/8d438672137e12110155e8d66424c0b2 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>
<!-- put markup and other contents here -->
<div id="root"></div>
</body>
</html>
// write ES2015 code and import modules from npm
// and then press "Execute" to run your program
import React, { PropTypes } from "react";
import { render } from "react-dom";
const MyComponent = (props) => <div>{JSON.stringify(props)}</div>;
MyComponent.propTypes = {
optionalProp: PropTypes.string,
anotherOptionalProp: PropTypes.string,
requiredProp: PropTypes.string.isRequired
}
MyComponent.defaultProps = {
optionalProp: "defaultValue"
}
render(<MyComponent requiredProp="A" />, document.getElementById("root"));
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"react": "0.14.8",
"react-dom": "0.14.8",
"babel-runtime": "6.6.1"
}
}
"use strict";
var _stringify = require("babel-runtime/core-js/json/stringify");
var _stringify2 = _interopRequireDefault(_stringify);
var _react = require("react");
var _react2 = _interopRequireDefault(_react);
var _reactDom = require("react-dom");
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 MyComponent = function MyComponent(props) {
return _react2.default.createElement(
"div",
null,
(0, _stringify2.default)(props)
);
};
MyComponent.propTypes = {
optionalProp: _react.PropTypes.string,
anotherOptionalProp: _react.PropTypes.string,
requiredProp: _react.PropTypes.string.isRequired
};
MyComponent.defaultProps = {
optionalProp: "defaultValue"
};
(0, _reactDom.render)(_react2.default.createElement(MyComponent, { requiredProp: "A" }), document.getElementById("root"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment