question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[drag-n-drop-plugin] store.getReadOnly is not a function

See original GitHub issue

We have an editor built with the draft-js-drag-n-drop-plugin and our error monitoring service is reporting a constant stream of this error:

screen shot 2017-10-21 at 6 52 55 pm

Looking at the drag-n-drop-plugin, this is happening because store.getReadOnly is first defined as undefined, and only assigned a proper function in initialize:

https://github.com/draft-js-plugins/draft-js-plugins/blob/d6182c5a8e029d3e4acba23e69cd277db94856b6/draft-js-drag-n-drop-plugin/src/index.js#L4-L16

Looking at createDecorator.js, it calls store.getReadOnly in the render method but that is throwing an error for some of our users:

https://github.com/draft-js-plugins/draft-js-plugins/blob/d6182c5a8e029d3e4acba23e69cd277db94856b6/draft-js-drag-n-drop-plugin/src/createDecorator.js#L23-L24

So for some reason render is called here before initialize of the main plugin is called. How can that happen? I can submit a patch to introduce a check to createDecorator (store && store.getReadOnly), but is that the right fix or is there something bigger going on?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
elie222commented, Jan 2, 2019

For anyone else that runs into this problem, I was creating the plugins in the render function. When I added an image to my editor I was updating the state which caused the editor to rerender and the plugins to be recreated.

I fixed this by creating the plugins in the constructor of my component instead.

To help Google index this, the error was coming from the createDecorators function 😃.

0reactions
sibeliuscommented, Sep 3, 2020

reopen if needed

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Plugin Architecture for Draft.js including Slack-Like ...
Any suggestions on how to get this to work? I even tried storing separate instances of mentionPlugin for each instance of editorState in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found