TypeError: Cannot read property 'reduce' of undefined
See original GitHub issueUsing: “@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:
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:
- Created 4 years ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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)}
Great to hear that!