Hello @reactcraft, thanks for reaching out.
@angeloashmore, explains and recommends the following:
This happens because that data could be any Rich Text block (a paragraph, heading, image, etc.). TypeScript can’t know what content is in that field, so it says that it can be any kind of Rich Text block. If you want to access the Rich Text data directly by reading description[0].text
, you can do an if
check first.
if ('text' in description[0]) {
// The text field is now available
}
Using @prismicio/helpers
’s asText()
function is better than accessing the text property directly.
import * as prismicH from '@prismicio/helpers'
prismicH.asText(description)