Skip to content

Instantly share code, notes, and snippets.

@3rd-Eden
Created April 1, 2015 12:10
Show Gist options
  • Save 3rd-Eden/ff9f7b732a9b6d898fe9 to your computer and use it in GitHub Desktop.
Save 3rd-Eden/ff9f7b732a9b6d898fe9 to your computer and use it in GitHub Desktop.
Using the BackBone .extend pattern with React
'use strict';
var React = require('react');
React.Component.extend = require('extendible');
var MyComponent = React.Component.extend({
state: {
what: 'extend'
},
render: function () {
return React.createElement('div', null, 'omg, this works with ' + this.state.what);
}
});
var MyClone = MyComponent.extend({
state: {
what: 'clones'
}
});
console.log(React.renderToString(React.createElement(MyComponent)));
console.log(React.renderToString(React.createElement(MyClone)));
<div data-reactid=".ci436j1fk0" data-react-checksum="-775350718">omg, this works with extend</div>
<div data-reactid=".a2qxm9ou80" data-react-checksum="-492562777">omg, this works with clones</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment