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.

Editor throws an "Cannot read property 'size' of undefined" error when using custom decorators

See original GitHub issue

I’m having a bit of trouble making the editor of draft-js-plugins-editor work with custom decorators when I use EditorState.createWithContent passing them as a parameter.

When I do that, the editor crashes, throwing a Cannot read property 'size' of undefined error. You can reproduce the error here: Reproducible example

If you remove the decorators parameter on line 82 (editorState: EditorState.createWithContent(convertFromRaw(initState)),), the error does not happen, but the decorators are not applied to the editor.

Am I doing something wrong?

Edit: Looks like the error happens on this line

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
glenn-allencommented, Jan 12, 2018

For anyone looking for a workaround, wrap your CompositeDecorator with the Draft JS Plugins’ MultiDecorator:

import { CompositeDecorator } from 'draft-js';
import MultiDecorator from 'draft-js-plugins-editor/lib/Editor/MultiDecorator';

....
const createDecorator = (...) => {
    const decorators = ...;
    return new MultiDecorator([new CompositeDecorator(decorators)]);
};
2reactions
freedomlangcommented, May 2, 2018

@winghouchan @pcsms @juliankrispel reproduced with latest version of draft-js-plugin-editor, will recheck it in the next few days

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read properties of undefined (reading 'length') - TrackJS
This message indicates that our code expects to have an object with a length property, but that object was not present.
Read more >
Cannot read property 'map' of undefined with @Input decorator
I have a child component that receives data via @Input() decorator. My goal is to create a new Object ...
Read more >
cannot read properties of undefined (reading 'map') typescript
This error occurs because react-scripts has a direct dependency on the 2.xx range of @typescript-eslint/parser and @typescript-eslint/eslint-plugin . You can ...
Read more >
Vue cannot read property of undefined
Originally Answered: how can I resolve a 'cannot read property connect of undefined' error on node js? For better results, provide the relevant...
Read more >
48 answers on StackOverflow to the most popular Angular ...
What is the Angular equivalent to an AngularJS $watch? Importing lodash into angular2 + typescript application; How to detect a route change 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