by coldcode · 11y ago · 0 comments
export let Button = {
render({props, state}) {
return <button>{props.text}</button>
}
}1) export and let are part of ES6 2) <button> is JSX, which is uses by Facebook's React but can also be used with Deku.
If you run that through babel, it turns it into valid ES5 Javascript which will run in any modern browser:
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var Button = {
render: function render(_ref) {
var props = _ref.props;
var state = _ref.state;
return React.createElement(
"button",
null,
props.text
);
}
};
exports.Button = Button;
(Note: By default Babel translates JSX into React.createElement calls; the Deku docs cover the one line config changed needed to make it us Deku element calls instead.) /** @jsx element */
export let Button = {
render({props, state}) {
return <button>{props.text}</button>
}
}
[1] http://babeljs.io/repl