Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<hr> tags not able to render #432

Open
MoritzCooks opened this issue Dec 13, 2022 · 2 comments
Open

<hr> tags not able to render #432

MoritzCooks opened this issue Dec 13, 2022 · 2 comments

Comments

@MoritzCooks
Copy link

I just ran across a problem with <hr> tags.
We have a contentful page that uses them and when I try to render the pages content with the documentToReactComponents from '@contentful/rich-text-react-renderer' I get this error:

error - TypeError: Cannot read properties of undefined (reading 'map')
    at nodeListToReactComponents (/.../node_modules/@contentful/rich-text-react-renderer/dist/rich-text-react-renderer.es5.js:414:18)
    at nodeToReactComponent (/.../node_modules/@contentful/rich-text-react-renderer/dist/rich-text-react-renderer.es5.js:429:24)
    at /.../node_modules/@contentful/rich-text-react-renderer/dist/rich-text-react-renderer.es5.js:415:40
    at Array.map (<anonymous>)
    at nodeListToReactComponents (/.../node_modules/@contentful/rich-text-react-renderer/dist/rich-text-react-renderer.es5.js:414:18)
    at nodeToReactComponent (/.../node_modules/@contentful/rich-text-react-renderer/dist/rich-text-react-renderer.es5.js:429:24)
    at documentToReactComponents (/.../node_modules/@contentful/rich-text-react-renderer/dist/rich-text-react-renderer.es5.js:486:12)
    at renderContentToReactComponent (webpack-internal:///./src/lib/richtextReactRenderer.tsx:115:107)
    at StaticPage (webpack-internal:///./src/components/StaticPage/StaticPage.tsx:112:115)
    at renderWithHooks (/.../node_modules/react-dom/cjs/react-dom-server.browser.development.js:5658:16) {
  page: '/de/presse'
}

I investigated a bit further and noticed that the hr node looks like this: { "nodeType": "hr" }
If I manually add a content key it works:

{
  "nodeType": "hr",
  "content": [],
}

Also the BLOCKS.HR element underlays the interface Block which by definition should have nodeType, data and content:

export interface Node {
    readonly nodeType: string;
    data: NodeData;
}
export interface Block extends Node {
    nodeType: BLOCKS;
    content: Array<Block | Inline | Text>;
}


ℹ️ I use the latest package version: "@contentful/rich-text-react-renderer": "^15.16.2",

@Sam-Morgan-Tyghe
Copy link

Im having the same issue

@martinang2
Copy link

I'm also having the same issue. Good find!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants