Skip to content

Commit

Permalink
Merge pull request #23 from JasonTolliver/feature/content_update_caus…
Browse files Browse the repository at this point in the history
…es_unneeded_rerender

Fix issues with updating props
  • Loading branch information
mzabriskie authored Jul 7, 2017
2 parents fb859c2 + cc24267 commit 05a6bc3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/components/TinyMCE.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,25 @@ const TinyMCE = React.createClass({
},

componentWillReceiveProps(nextProps) {
if (!isEqual(this.props.config, nextProps.config)) {
this._init(nextProps.config, nextProps.content);
}
if (!isEqual(this.props.id, nextProps.id)) {
this.id = nextProps.id;
}
if (!isEqual(this.props.config, nextProps.config) || !isEqual(this.props.id, nextProps.id)) {
this._init(clone(nextProps.config), nextProps.content);
return;
}

const editor = tinymce.EditorManager.get(this.id);
if (!isEqual(editor.getContent({format: 'raw'}), nextProps.content)) {
editor.setContent(nextProps.content);

editor.selection.select(editor.getBody(), true);
editor.selection.collapse(false);
}
},

shouldComponentUpdate(nextProps) {
return (
!isEqual(this.props.content, nextProps.content) ||
!isEqual(this.props.config, nextProps.config)
);
},
Expand Down

0 comments on commit 05a6bc3

Please sign in to comment.