prismicio / prismic-react

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

fix: render Slices in the correct order in `<SliceZone>` #104

Closed angeloashmore closed 2 years ago

angeloashmore commented 2 years ago

Types of changes

Description

Related issue: #101

This PR fixes an issue where Slices could render in the wrong order in <SliceZone>.

The bug only occurs when the list of Slices changes after the first render. The bug occurs because the key prop is generated using the Slice's object. If multiple Slices contain the same payload (e.g. same Slice type, content, etc.), they would have duplicate keys.

To reduce the possibility of key collisions, this PR appends the Slice's index to the key.

Checklist:

🔑