diff --git a/src/react-contenteditable.js b/src/react-contenteditable.js index 3db2966..a42ea6a 100644 --- a/src/react-contenteditable.js +++ b/src/react-contenteditable.js @@ -4,9 +4,10 @@ import deepEqual from 'fast-deep-equal'; let stripNbsp = str => str && str.replace(/ |\u202F|\u00A0/g, ' '); export default class ContentEditable extends React.Component { - constructor() { + constructor(props) { super(); this.emitChange = this.emitChange.bind(this); + this.lastHtml = props.html; } render() { @@ -54,8 +55,7 @@ export default class ContentEditable extends React.Component { if (this.htmlEl && this.props.html !== this.htmlEl.innerHTML) { // Perhaps React (whose VDOM gets outdated because we often prevent // rerendering) did not update the DOM. So we update it manually now. - this.htmlEl.innerHTML = this.props.html; - this.lastHtml = this.props.html; + this.htmlEl.innerHTML = this.lastHtml = this.props.html; } }