Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onReady is called after <CKEditor> is unmounted #469

Closed
stonebk opened this issue Apr 17, 2024 · 3 comments
Closed

onReady is called after <CKEditor> is unmounted #469

stonebk opened this issue Apr 17, 2024 · 3 comments
Assignees
Labels
resolution:resolved This issue was already resolved (e.g. by another ticket). squad:collaboration Issue to be handled by the Collaboration team.
Milestone

Comments

@stonebk
Copy link

stonebk commented Apr 17, 2024

A bit of an edge case I ran into while testing. I have a component that looks something like this:

    const [editor, setEditor] = useState<HeadlessEditor>(); 
    const onReadyCallback = useCallback(
      (editor) => {
        setEditor(editor);
      },
      []
    );

    return <CKEditor config={config} editor={MyEditor} onReady={onReadyCallback}  />;

I have some small tests that run faster than it takes to initialize the editor, so <CkEditor> unmounts before onReady is called, but onReady is called anyways resulting in the following warning:

  console.error
    Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

My guess is that this is because the onReady call happens in a setTimeout:

				// The `onReady` callback should be fired once the `editor` property
				// can be reached from the `<CKEditor>` component.
				// Ideally this part should be moved to the watchdog item creator listeners.
				setTimeout( () => {
					if ( this.props.onReady ) {
						this.props.onReady( editor );
					}
				} );

Would be nice to not have to work around this!

@Mati365 Mati365 self-assigned this Apr 22, 2024
DawidKossowski pushed a commit that referenced this issue May 9, 2024
Fix: The quick rerendering, especially in `React.StrictMode`, will no longer cause the editor errors. Closes #442, #469, #471, #476.
@Mati365
Copy link
Member

Mati365 commented Jun 6, 2024

@stonebk Can you check if this issue is still reproducible? We managed to release few modifications in initialization mechanism and upgrading might solve the issue.

@stonebk
Copy link
Author

stonebk commented Jun 17, 2024

@stonebk Can you check if this issue is still reproducible? We managed to release few modifications in initialization mechanism and upgrading might solve the issue.

I will take a look, thanks!

@stonebk
Copy link
Author

stonebk commented Jun 20, 2024

@Mati365 yay! v7.0.0 looks to have fixed this!

@stonebk stonebk closed this as completed Jun 20, 2024
@Witoso Witoso added this to the iteration 75 milestone Jun 24, 2024
@Witoso Witoso added the squad:collaboration Issue to be handled by the Collaboration team. label Jun 24, 2024
@Reinmar Reinmar added the resolution:resolved This issue was already resolved (e.g. by another ticket). label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution:resolved This issue was already resolved (e.g. by another ticket). squad:collaboration Issue to be handled by the Collaboration team.
Projects
None yet
Development

No branches or pull requests

4 participants