diff --git a/packages/react/src/ReactRenderer.tsx b/packages/react/src/ReactRenderer.tsx index f38ceb554ba..6a497efc867 100644 --- a/packages/react/src/ReactRenderer.tsx +++ b/packages/react/src/ReactRenderer.tsx @@ -78,15 +78,17 @@ export class ReactRenderer { this.reactElement = - flushSync(() => { - if (this.editor?.contentComponent) { - this.editor.contentComponent.setState({ - renderers: this.editor.contentComponent.state.renderers.set( - this.id, - this, - ), - }) - } + queueMicrotask(() => { + flushSync(() => { + if (this.editor?.contentComponent) { + this.editor.contentComponent.setState({ + renderers: this.editor.contentComponent.state.renderers.set( + this.id, + this, + ), + }) + } + }) }) } @@ -100,16 +102,18 @@ export class ReactRenderer { } destroy(): void { - flushSync(() => { - if (this.editor?.contentComponent) { - const { renderers } = this.editor.contentComponent.state - - renderers.delete(this.id) - - this.editor.contentComponent.setState({ - renderers, - }) - } + queueMicrotask(() => { + flushSync(() => { + if (this.editor?.contentComponent) { + const { renderers } = this.editor.contentComponent.state + + renderers.delete(this.id) + + this.editor.contentComponent.setState({ + renderers, + }) + } + }) }) } }