React Base Fiddle (JSX)

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

by FGRibreau

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>
<script type="text/javascript">
    var twttr ={
    txt:{
    autoLink: function(text){
alert('YEAH!');
    return text.replace('http://google.com', '<a href="http://google.com">google.com</a>');
    }}
    };
</script>
<div id="container">
    <!-- This element's contents will be replaced with your component. -->
</div>

JavaScript 1.7

var TextView = React.createClass({
    propTypes: {
      text: React.PropTypes.string.isRequired
    },
    
    getHTML:function(){
        return this.props.text;
    },
    
    render: function() {
        return <div>{this.getHTML()}</div>;
    }
});

function URLDecorator(TextViewComponent){

    (function(super$getHTML){
    debugger;
        TextViewComponent.prototype.getHTML = function getHTMLWithUrl(){
            return twttr.txt.autoLink(super$getHTML.call(this));
        };
    debugger;
    })(TextViewComponent.prototype.getHTML);
    
    return TextViewComponent;
}

var TextViewWithURL = URLDecorator(TextView);
debugger;
 
React.render(<TextViewWithURL text="hello world http://google.com" />, document.getElementById('container'));