Skip to content

Instantly share code, notes, and snippets.

@myndzi
Created August 6, 2015 16:12
Show Gist options
  • Save myndzi/ed37fedd4c1957f29d1b to your computer and use it in GitHub Desktop.
Save myndzi/ed37fedd4c1957f29d1b to your computer and use it in GitHub Desktop.
var DocumentEdit = React.createClass({
mixins: [CoerceDocumentMixin, PerfMixin],
....
});
module.exports = {
getInitialState() {
return {
document: this._coerceDocument(this.props.document)
}
},
_updateDocument(doc) {
this.setState({
document: _coerceDocument(doc)
});
},
_coerceDocument(data) {
var doc = Object.assign({ }, this.state.document, data);
//... do stuff to 'doc'
return doc;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment