ckeditor/ckeditor5-react

Quick rerendering causes editor issues

DawidKossowski opened this issue · 2 comments

In StrictMode or in situations where the application quickly rerenders, the next editor instance is rerendered or attempts to rerender before the previous instance is destroyed, especially when the editor uses async calls (for example, for getting the cloud services token).

We've implemented a mechanism to keep track of the destroying promise (editorDestructionInProgress) and to wait for it to resolve before initializing the next editor instance. However, in some cases, the next editor instance is initialized before the previous one starts the destroying process (editorDestructionInProgress is null). This results in two editor instances on the page or in an error: CKEditorError: editor-source-element-already-used. The outcome depends on the integration.

This issue is non-deterministic and depends on the React versions, but it can be reproduced by adding the config with cloudServices property (in our demo: demo-react-18) to trigger a request for a token during editor initialization.

@Mati365 please check this mechanism in both integrations: CKEditor and useMultiRootEditor.