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.

TypeError: Cannot read property 'reduce' of undefined

See original GitHub issue

Using: “@contentful/rich-text-react-renderer”: “^13.2.0”,

I’ve setup a Rich Content Type within Contentful and added all of my content within it, the content is a combination of plain text and an unordered list. I am pulling in the content using “gatsby-source-contentful”: “^2.1.15” and querying it using GraphQL.

When I do a console log like so console.log('AboutPage', data.data.contentfulAboutPage.mainBody) within my page I get this response:

Screenshot 2019-07-26 15 45 22

However if I use the {documentToReactComponents(data.data.contentfulAboutPage.mainBody)} function I get the error message - TypeError: Cannot read property ‘reduce’ of undefined.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
GlueDigiStucommented, Jul 29, 2019

Ah I’ve just worked out what I was doing wrong. The {documentToReactComponents(data.data.contentfulAboutPage.mainBody)} call needed to be instead {documentToReactComponents(data.data.contentfulAboutPage.mainBody.json)}

0reactions
sbezludnycommented, Jul 30, 2019

Great to hear that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'reduce' of undefined in react
I have a form in which I am asking the user to input field values for a couple of fields, storing the field...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Js-error "TypeError: Cannot read property 'reduce ... - YouTrack
Js-error "TypeError: Cannot read property 'reduce' of undefined" on code rewiews tab ; Released in build, 6.5 ; Assignee, Maksim Ryzhikov ; Priority,...
Read more >
Cannot read property 'reduce' of undefined in react-Reactjs
Coding example for the question TypeError: Cannot read property 'reduce' of undefined in react-Reactjs.
Read more >
Uncaught TypeError: Cannot read property of undefined In
This error occurs in Chrome Browser when you read a property or call a method on an undefined object . There are a...
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