The README.md shows the way to render rich text as the following:
const options = {
renderNode: {
[BLOCKS.EMBEDDED_ENTRY]: (node) => {
console.log(node)
const { title, description } = node.data.target.fields;
return <CustomComponent title={title} description={description} />
}
}
};
My implementation is basically identical but when I console.log(node)
it gives the following result:
Source:
https://imgur.com/XlX4dAd
Clearly there is no fields
in node.data.target
I am super confused because the same code was working a few days ago but now its bust.
Same as: https://github.com/contentful/rich-text/issues/147
Hi, did you resolve this as i have the exact same issue but using the C# SDK, it was working and now it doesn’t. This is my question post:
https://www.contentfulcommunity.com/t/issue-c-project-and-embedded-resource-in-rich-text-box/6435
Thanks
Chris
jere
3
Solved this for Gatsby:
Had the exact same error (node.data.target
returned “undefined”). The issue was that I didn’t include __typename
and contentful_id
in the query.
So instead of doing this:
... on ContentfulAsset {
file {
url
contentType
}
gatsbyImageData
description
}
I did this:
... on ContentfulAsset {
__typename
file {
url
contentType
}
gatsbyImageData
description
contentful_id
}
And it started working!