diff --git a/src/editor.js b/src/editor.js index bb3a8ba0..1a5b6222 100644 --- a/src/editor.js +++ b/src/editor.js @@ -19,12 +19,12 @@ export default class ReactMediumEditor extends React.Component { } componentDidMount() { - const dom = ReactDOM.findDOMNode(this); + this.dom = ReactDOM.findDOMNode(this); - this.medium = new MediumEditor(dom, this.props.options); + this.medium = new MediumEditor(this.dom, this.props.options); this.medium.subscribe('editableInput', e => { this._updated = true; - this.change(dom.innerHTML); + this.change(this.dom.innerHTML); }); } @@ -36,6 +36,10 @@ export default class ReactMediumEditor extends React.Component { this.medium.destroy(); } + shouldComponentUpdate(nextProps, nextState) { + return nextProps.text !== this.dom.innerHTML; + } + componentWillReceiveProps(nextProps) { if (nextProps.text !== this.state.text && !this._updated) { this.setState({ text: nextProps.text });