jpuri / jpuri/html-to-draftjs

Cannot read properties of undefined (reading 'createWithContent')

Open
#128 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
163
Forks
104
PR merge metrics
No merged PRs in 30d

Description

Running this code

const html = "<p></p>";
const contentBlock = htmlToDraft(html);
const { contentBlocks, entityMap } = contentBlock;
const contentState = ContentState.createFromBlockArray(contentBlocks, entityMap);
const editorState = EditorState.createWithContent(contentState);

And getting this error:

Uncaught TypeError: Cannot read properties of undefined (reading 'createWithContent')
at TextBoxComponent.tsx:88:1
at commitHookEffectListMount (react-dom.development.js:23150:1)
at commitPassiveMountOnFiber (react-dom.development.js:24926:1)
at commitPassiveMountEffects_complete (react-dom.development.js:24891:1)
at commitPassiveMountEffects_begin (react-dom.development.js:24878:1)
at commitPassiveMountEffects (react-dom.development.js:24866:1)
at flushPassiveEffectsImpl (react-dom.development.js:27039:1)
at flushPassiveEffects (react-dom.development.js:26984:1)
at react-dom.development.js:26769:1
at workLoop (scheduler.development.js:266:1)

I've Googled it a bit, and came across a couple of times it was mentioned, but no concrete solution:
here
and here

Packages:

draft-js@0.11.7
react-draft-wysiwyg@1.15.0
html-to-draftjs@1.4.0

The code is as basic as it could be - so I'm not sure what the issue could be!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The payload names no repository files or tests. Start by reproducing the snippet with draft-js@0.11.7, react-draft-wysiwyg@1.15.0, and html-to-draftjs@1.4.0, then trace why EditorState is undefined; done means identifying a reproducible cause and documenting the confirmed resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript, react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.