block is not a BlockNode v10.5
See original GitHub issueDo 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:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
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?
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