Skip to content

Commit

Permalink
Prevent possible race conditions while accessing watchdog in initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Mati365 committed Jun 7, 2024
1 parent 6b114d7 commit f2118e1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ckeditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ export default class CKEditor<TEditor extends Editor> extends React.Component<Pr
}

const watchdog = ( () => {
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 );
}

Expand Down

0 comments on commit f2118e1

Please sign in to comment.