Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix issues with updating props
- A simple content change was causing a complete re-render
- Altering id prop was not initiating re-_init causing a selector mis-match
- Initiating re-_init was not cloning the new props, _init was then adding new properties and triggering false re-renders
  • Loading branch information
JasonTolliver committed Jan 21, 2016
commit 4b5fca806837c8225ab7b7534e3905f2a913a893
11 changes: 7 additions & 4 deletions lib/components/TinyMCE.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ 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;
}
if (!isEqual(this.props.content, nextProps.content)) {
tinymce.EditorManager.get(this.id).setContent(nextProps.content);
}
},

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