The problem seems to just be that
- when using the graphQL API we get
type
- but when using the rest API we get
slice_type
.
This was posted yesterday: Slice type does not work with @prismicio/react v2 SliceZone Component
This is a strange discrepancy and it would be good to get this fixed asap... It's very confusing
This is what I had to do to make it work, but it's a bit hacky. Typescript doesn't complain anymore
{myContentPage?.body1 && (
<SliceZone
slices={myContentPage?.body1.map((slice) => {
return { ...slice, slice_type: slice.type ?? ''};
})}
/>
)}
(obviously I need other props as well, I'm just showing the minimum required to fix my initial error)