React Base Fiddle (JSX)

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

HTML

<script src="http://fb.me/JSXTransformer-0.12.1.js"></script>
<script src="http://fb.me/react-with-addons-0.12.1.js"></script>
<script src="http://facebook.github.io/react/js/jsfiddle-integration.js"></script>

JavaScript 1.7

if (!Object.assign) {
  Object.defineProperty(Object, "assign", {
    enumerable: false,
    configurable: true,
    writable: true,
    value: function(target, firstSource) {
      "use strict";
      if (target === undefined || target === null)
        throw new TypeError("Cannot convert first argument to object");
      var to = Object(target);
      for (var i = 1; i < arguments.length; i++) {
        var nextSource = arguments[i];
        if (nextSource === undefined || nextSource === null) continue;
        var keysArray = Object.keys(Object(nextSource));
        for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
          var nextKey = keysArray[nextIndex];
          var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
          if (desc !== undefined && desc.enumerable) to[nextKey] = nextSource[nextKey];
        }
      }
      return to;
    }
  });
}

var CommentBox = React.createClass({
  getInitialState: function() {
    return {data: [
      { id: 1, author: "john", text: "foo" },
      { id: 2, author: "bob", text: "bar" }
    ]};
  },
  handleCommentEdit: function(id, text) {
    
    var existingComment = this.state.data.filter(function(c) { return c.id == id; })[0];
    var updatedComment=Object.assign({}, existingComment, {text:text}); 
    var index = this.state.data.indexOf(existingComment); 
    
    var newState = React.addons.update(this.state, {data: {$splice: [[index,1,updatedComment]]}});
    this.setState(newState);
    
  },
  
  render: function() {
        return <div>{ this.state.data.map(function(comment){
          return <div key={comment.id}>{comment.text} {comment.author}</div>
        }) }
        <button onClick={this.handleCommentEdit.bind(this,2,"second comment edited")}>Click</button></div>;
   }
});
 
React.render(<CommentBox />, document.body);