JSFiddle - React, Tailwind, and code Playground

by insin

HTML

<script src="http://fb.me/JSXTransformer-0.10.0.js"></script>
<script src="http://fb.me/react-with-addons-0.10.0.js"></script>
<script src="http://fb.me/react-js-fiddle-integration.js"></script>

JavaScript 1.7

/** @jsx React.DOM */

var Parent = React.createClass({
    clickHandler: function(item, e) {
        console.log("clickHandler");
        console.log(item.text)
    },
    render: function() {
        var children = this.props.content.map(function(item, idx) {
            return <Child key={"child"+idx} item={item} onClick={this.clickHandler.bind(this, item)} />
        }.bind(this));
        return (
            <div>{children}</div>
        );
    }
});

var Child = React.createClass({
    render: function() {
        return this.transferPropsTo(
            <div>{this.props.item.text}</div>
        );
    }
});
 
React.renderComponent(<Parent content={[
  {text: 'child1'}
, {text: 'child2'}
]}/>, document.body);