Skip to content

Instantly share code, notes, and snippets.

@insin
Last active August 29, 2015 14:13
Show Gist options
  • Save insin/0e6ed582899737164707 to your computer and use it in GitHub Desktop.
Save insin/0e6ed582899737164707 to your computer and use it in GitHub Desktop.
>>> var C = React.createClass({
getInitialState: function() {
return {1: 2}
},
render: function() {
return React.createElement('div', 'test')
}
})
undefined
>>> var original = C.type.prototype.getInitialState
undefined
>>> C.type.prototype.getInitialState = function() {
return Object.assign({3: 4}, original())
}
function C.type.prototype.getInitialState()
>>> var c = React.render(React.createElement(C), document.body)
undefined
>>> c.state
Object { 1: 2, 3: 4 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment