diff --git a/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/index.js b/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/index.js index 02ae9090b0..e2d8bf10b8 100644 --- a/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/index.js @@ -51,9 +51,9 @@ class Wysiwyg extends React.Component { editorState: EditorState.createEmpty(), isDraging: false, isFocused: false, + isFullscreen: false, isPreviewMode: false, headerValue: '', - isFullscreen: false, }; this.focus = () => { this.setState({ isFocused: true }); @@ -84,6 +84,38 @@ class Wysiwyg extends React.Component { } } + shouldComponentUpdate(nextProps, nextState) { + if (nextState.editorState !== this.state.editorState) { + return true; + } + + if (nextProps.resetProps !== this.props.resetProps) { + return true; + } + + if (nextState.isDraging !== this.state.isDraging) { + return true; + } + + if (nextState.isFocused !== this.state.isFocused) { + return true; + } + + if (nextState.isFullscreen !== this.state.isFullscreen) { + return true; + } + + if (nextState.isPreviewMode !== this.state.isPreviewMode) { + return true; + } + + if (nextState.headerValue !== this.state.headerValue) { + return true; + } + + return false; + } + componentDidUpdate(prevProps) { // Handle resetProps if (prevProps.resetProps !== this.props.resetProps) { @@ -362,7 +394,7 @@ class Wysiwyg extends React.Component { handleDrop = e => { e.preventDefault(); - + console.log('kkks'); if (this.state.isPreviewMode) { return this.setState({ isDraging: false }); } diff --git a/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/previewWysiwyg.js b/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/previewWysiwyg.js index 27fe03f0de..a0c05f9293 100644 --- a/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/previewWysiwyg.js +++ b/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/previewWysiwyg.js @@ -57,7 +57,7 @@ const decorator = new CompositeDecorator([ }, ]); -class PreviewWysiwyg extends React.Component { +class PreviewWysiwyg extends React.PureComponent { state = { editorState: EditorState.createEmpty(), isMounted: false }; componentDidMount() {