Skip to content

Commit 4b5fca8

Browse files
committed
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
1 parent 15831fd commit 4b5fca8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/components/TinyMCE.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,20 @@ const TinyMCE = React.createClass({
5656
},
5757

5858
componentWillReceiveProps(nextProps) {
59-
if (!isEqual(this.props.config, nextProps.config)) {
60-
this._init(nextProps.config, nextProps.content);
61-
}
6259
if (!isEqual(this.props.id, nextProps.id)) {
6360
this.id = nextProps.id;
6461
}
62+
if (!isEqual(this.props.config, nextProps.config) || !isEqual(this.props.id, nextProps.id)) {
63+
this._init(clone(nextProps.config), nextProps.content);
64+
return;
65+
}
66+
if (!isEqual(this.props.content, nextProps.content)) {
67+
tinymce.EditorManager.get(this.id).setContent(nextProps.content);
68+
}
6569
},
6670

6771
shouldComponentUpdate(nextProps) {
6872
return (
69-
!isEqual(this.props.content, nextProps.content) ||
7073
!isEqual(this.props.config, nextProps.config)
7174
);
7275
},

0 commit comments

Comments
 (0)