React Base Fiddle (JSX)

Starting point for creating JSFiddles with React. This uses React with Addons.

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/JSXTransformer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/react-with-addons.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>
<div id="container">
    <!-- This element's contents will be replaced with your component. -->
</div>

CSS

.light-it-up {
    background-color: indianred;
    color: white;
}

JavaScript 1.7

var items = [
{id: 1, highlighted: false, text: "item1"},
{id: 2, highlighted: true, text: "item2"},
{id: 3, highlighted: false, text: "item3"},
];


var MyComponent = React.createClass({
    render: function() {
        return <div className={this.props.highlighted ? 'light-it-up' : ''}>{this.props.text}</div>;
    }
});


var MyList = React.createClass({

    toggleHighlight: function() {
        this.props.items.forEach(function(v){
            v.highlighted = !v.highlighted;
        });
        
        // Want to trigger highlight change on children
        // IS THIS CORRECT?
        this.setState({});
    },
    
    render: function() {
        return <div>
        <button onClick={this.toggleHighlight}>Toggle highlight</button>
              {this.props.items.map(function(item) {
                return <MyComponent key={item.id} text={item.text} highlighted={item.highlighted}/>;
              })}
            </div>
            ;
            
    }
});
 
React.render(<MyList items={items}/>, document.getElementById('container'));