prismicio / prismic-react

React components and hooks to fetch and present Prismic content
https://prismic.io/docs/technologies/homepage-reactjs
Apache License 2.0
152 stars 40 forks source link

fix: `<TodoSliceComponent />` compat with Slice Mapper #202

Closed lihbr closed 7 months ago

lihbr commented 7 months ago

Types of changes

Description

Mapped slices would cause the <TODOSliceComponent /> component to throw because of a different interface used by mapped slices (slice type being top level instead of nested under the slice property).

This standardizes the props given to <TODOSliceComponent /> so everything keeps working smoothly based on our Svelte implementation: https://github.com/prismicio/prismic-svelte/blob/master/src/SliceZone/SliceZone.svelte#L118-L128

I first explored adapting the <TODOSliceComponent /> to support different interfaces instead, but it resulted in messier code in my opinion: https://github.com/prismicio/prismic-vue/blob/95d5771b51dc45df5bd6663178afceae8942dc4c/src/components/SliceZone.ts#L263-L280 (hence the sister PR for Vue: https://github.com/prismicio/prismic-vue/pull/70)

Checklist:

github-actions[bot] commented 7 months ago

size-limit report 📦

Path Size
./dist/index.cjs 8.03 KB (+0.1% 🔺)
./dist/index.js 6.05 KB (+0.13% 🔺)
./dist/react-server.cjs 7.22 KB (+0.14% 🔺)
./dist/react-server.js 5.58 KB (+0.2% 🔺)
angeloashmore commented 7 months ago

Thanks, good catch! This version is simple to read.