0

Thank you so, so much for your time looking at this

I'm using React and Prismic I'm trying to apply RichText (https://prismic.io/docs/technologies/rendering-the-rich-text-and-title-field-reactjs) to render the text but do not work on map.

My guess is that I'm loosing some logic here but I can't understand what is This show the content without rendering:

{prismicDoc?.data?.contenido?.map(x => x?.text || null)}

This show me an error:

{RichText.render(prismicDoc?.data?.contenido?.map(x => x?.text || null))}

The error is TypeError: Cannot read properties of undefined (reading 'map')

Could you please let me know what I'm doing wrong?

Thanks Laura

Rolanda
  • 328
  • 1
  • 9
  • where is prismicDoc being defined? – MWO Feb 19 '22 at 22:34
  • At the begging of the class: const SinglePage = ({ match }) => { const [prismicDoc, setPrismicDoc] = useState(null); const [notFound, toggleNotFound] = useState(false); const uid = match.params.uid; // Get the blog post document from Prismic useEffect(() => { const fetchPrismicData = async () => { try { const doc = await client.getByUID('paginas', uid); if (doc) { setPrismicDoc(doc); – Rolanda Feb 20 '22 at 14:57

0 Answers0