Skip to content

Commit

Permalink
Use componentWillReceiveProps for manipulation instead of shouldCompo…
Browse files Browse the repository at this point in the history
…nentUpdate
  • Loading branch information
ellatrix committed May 10, 2017
1 parent 02b4fc2 commit d81a2b6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions blocks/editable/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ export default class TinyMCE extends wp.element.Component {
this.initialize();
}

shouldComponentUpdate( nextProps ) {
const isEmpty = String( nextProps.isEmpty );

if ( this.editorNode.getAttribute( 'data-is-empty' ) !== isEmpty ) {
this.editorNode.setAttribute( 'data-is-empty', isEmpty );
}

shouldComponentUpdate() {
// We must prevent rerenders because TinyMCE will modify the DOM, thus
// breaking React's ability to reconcile changes.
//
// See: https://github.com/facebook/react/issues/6802
return false;
}

componentWillReceiveProps( nextProps ) {
const isEmpty = String( nextProps.isEmpty );

if ( this.editorNode.getAttribute( 'data-is-empty' ) !== isEmpty ) {
this.editorNode.setAttribute( 'data-is-empty', isEmpty );
}
}

componentWillUnmount() {
if ( ! this.editor ) {
return;
Expand Down

0 comments on commit d81a2b6

Please sign in to comment.