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

[Bug] TypeError: Cannot read property 'deactivate' of null #1400

Closed
mochicode opened this issue Oct 24, 2020 · 10 comments
Closed

[Bug] TypeError: Cannot read property 'deactivate' of null #1400

mochicode opened this issue Oct 24, 2020 · 10 comments
Labels

Comments

@mochicode
Copy link

I am trying to use editor.js with react hooks and every time I am trying to destroy the editor I get the following error:
TypeError: Cannot read property 'deactivate' of null

From what I can see, when you call the destroy method on the editor instance the destroy methods of BlockSettings and Toolbox are being called twice.

  1. src/codex.ts: the first call to destroy happens in here
  2. src/components/modules/toolbar/index.ts: the second call to destroy happens here

Both destroy methods of BlockSettings and Toolbox are setting this.flipper = null after a calling this.flipper.deactivate() and thus the error message: TypeError: Cannot read property 'deactivate' of null

Steps to reproduce:
Demo App: https://react-editor.vercel.app/
Demo source code: https://github.com/riezler-co/editorjs-demo
The modified editorjs code: https://github.com/riezler-co/editor.js

Expected behavior:
I can destroy the editor without throwing an exception

Screenshots:
https://drive.google.com/file/d/1DMvTvP2MKnCPiOSW92tMKlGqTw1TBRHU/view?usp=sharing

Device, Browser, OS:
Version 86.0.4240.111 (Official Build) (64-bit)

Editor.js version:
2.19.0

Plugins you use with their versions:
none

@mochicode mochicode added the bug label Oct 24, 2020
@mochicode
Copy link
Author

Related Issue: #919 (comment)

@StarAzure
Copy link

StarAzure commented Oct 27, 2020

Please fix this bug with 2.19.0 -

Cannot read property 'deactivate' of null

Happening here
value: function() { this.flipper.deactivate(), this.flipper = null, this.removeAllNodes() }

Does not happen with 2.18.0

@sis-dk
Copy link
Contributor

sis-dk commented Oct 29, 2020

Duplicate of #1380

@sam26880
Copy link

sam26880 commented Nov 4, 2020

Is there any update on this issue? I'm seeing this as well.

I ran into this issue when using the readOnly flag set to true. When I remove the flag, it works fine.

@lysyi3m
Copy link

lysyi3m commented Nov 5, 2020

Is there any updates here? it breaks core functionality, since it doesn't allow to properly destroy previously created editor instance.

@aomini
Copy link

aomini commented Nov 10, 2020

having the same problem here as well.
Any updates?

@aomini
Copy link

aomini commented Nov 10, 2020

Not sure if this is ideal but for the time being
I tried this in my react component

if (instance) {
      document.querySelector(`#${holder} .codex-editor`).remove();
    }

@D1verGW
Copy link

D1verGW commented Nov 18, 2020

Hello!
First of all - nice works! Amazing tool, I'm really like it!
But...
Any updates on this one?
I've tried to use editor with my ReactJS code, and by default I have an issue described in the topic head, it makes me suffer...

@neSpecc
Copy link
Member

neSpecc commented Nov 20, 2020

Duplicate #1380

@neSpecc neSpecc closed this as completed Nov 20, 2020
@alxndr
Copy link

alxndr commented Aug 5, 2021

I see this error in v2.22.2, when testing a custom Tool in a headless environment (using Cypress).

Using .click({force:true}) allows the tests to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants