Created
April 1, 2015 12:10
-
-
Save 3rd-Eden/ff9f7b732a9b6d898fe9 to your computer and use it in GitHub Desktop.
Using the BackBone .extend pattern with React
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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