From f2118e1b560b2566845e914990b1de87803ae7b3 Mon Sep 17 00:00:00 2001 From: Mateusz Baginski Date: Fri, 7 Jun 2024 12:56:25 +0200 Subject: [PATCH] Prevent possible race conditions while accessing watchdog in initializer --- src/ckeditor.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ckeditor.tsx b/src/ckeditor.tsx index 61cd9d2c..482ea5f7 100644 --- a/src/ckeditor.tsx +++ b/src/ckeditor.tsx @@ -223,7 +223,9 @@ export default class CKEditor extends React.Component { - if ( isContextWatchdogValueWithStatus( 'initialized', this.context ) ) { + // There is small delay where React did not update the context yet but watchdog is already destroyed. + // However editor should be created again in such case, after receiving new context. + if ( isContextWatchdogValueWithStatus( 'initialized', this.context ) && this.context.watchdog.state !== 'destroyed' ) { return new EditorWatchdogAdapter( this.context.watchdog ); }