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.

block is not a BlockNode v10.5

See original GitHub issue

Do you want to request a feature or report a bug? Bug

What is the current behavior? I call convertToRaw using the contentState that gets passed from whatever sends things through the blockRenderMap. (props.children.props.contentState). It throws an error that says ‘block is not a BlockNode’

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. You can use this jsfiddle to get started: https://jsfiddle.net/stopachka/m6z0xn4r/. Make a custom block render map.

const SOME_COMPONENT = (props) => { 
  convertToRaw(props.children.props.contentState); 
  return whatever; 
}

'unstyled': {
  element: SOME_COMPONENT
}

What is the expected behavior? convertToRaw converts the contentState.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js? Worked in 10.4, broke in 10.5 (stuff relating to convertToRaw was changed). Mac OS Sierra 10.12.6

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
DerMambocommented, Oct 1, 2020

When you patch convertFromDraftStateToRaw.js in line 42 you can avoid that issue.

Instead of: if (block instanceof ContentBlock) {

Use if (block && block.constructor.name === "ContentBlock") {

Imho it should be “save enough”. Would it make sense to set a PR with this?

5reactions
githubflubcommented, May 23, 2018

Closing since this is an npm/npm link/dependency management issue/ rather than a problem with draft-js@0.10.5

This stackoverflow answer explains this BlockNode error. https://stackoverflow.com/a/34645112

This Medium article describes the problem I was having perfectly https://medium.com/@penx/managing-dependencies-in-a-node-package-so-that-they-are-compatible-with-npm-link-61befa5aaca7

Helpful article on npm link https://medium.com/@alexishevia/the-magic-behind-npm-link-d94dcb3a81af

Read more comments on GitHub >

github_iconTop Results From Across the Web

DraftJs: Invariant Violation: block is not a BlockNode when ...
@dwjohnston I have visited that issue 5 times and played around with different versions of draft js. I even downgraded draft-js to 0.10.0...
Read more >
gyo on Twitter: ""Uncaught Error: block is not a BlockNode ...
"Uncaught Error: block is not a BlockNode" when using draft-js v0.10.5 · Issue #143 · HubSpot/draft-convert ... 5:18 AM · Apr 8, 2020....
Read more >
try...catch - JavaScript - MDN Web Docs - Mozilla
The try...catch statement is comprised of a try block and either a catch block, a finally block, or both. The code in the...
Read more >
How to make A block node contain arbitrary inline children or ...
According to the HTML specification, a block element can contain either block elements or inline elements. Although ProseMirror does not ...
Read more >
Expression trees - Math.js
The node itself is cloned, its childs are not cloned. ... Node of an expression tree const evaluate = node.evaluate({x: 3}) // returns...
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