Skip to content

Commit

Permalink
Classic block: Fix content syncing effect for React StrictMode (WordP…
Browse files Browse the repository at this point in the history
…ress#62051)


Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
  • Loading branch information
4 people authored and carstingaxion committed Jun 4, 2024
1 parent 16e2b29 commit 6d58249
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/block-library/src/freeform/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,15 @@ function ClassicEdit( {
}

const editor = window.tinymce.get( `editor-${ clientId }` );
const currentContent = editor?.getContent();
if ( ! editor ) {
return;
}

const currentContent = editor.getContent();
if ( currentContent !== content ) {
editor.setContent( content || '' );
}
}, [ content ] );
}, [ clientId, content ] );

useEffect( () => {
const { baseURL, suffix } = window.wpEditorL10n.tinymce;
Expand Down Expand Up @@ -227,6 +230,7 @@ function ClassicEdit( {
onReadyStateChange
);
wp.oldEditor.remove( `editor-${ clientId }` );
didMount.current = false;
};
}, [] );

Expand Down

0 comments on commit 6d58249

Please sign in to comment.