slice-machine
slice-machine copied to clipboard
Add uid for repeatable zone/list items
When using repeatable zones with Nextjs, Nexjs needs a unique key for every mapped item. I can now only give it the text itself or the index number.
The problem with the index number is that it's a variable number so not unique. For instance removing items would change this number.
When using the text as a key, you must not repeat the same text. Or the key won't be unique. An uid per item would solve this.
Hi @bosbode,
This is not really the use case for UID fields, they are a Unique ID for the document itself, used for the URL.
We recommend using the text as you suggested, although there are issues as you suggested.
https://github.com/prismicio-community/nextjs-starter-prismic-multi-language/blob/e14ae499cd3ad9fc566ff977a2641bad997a2b8e/slices/TextWithFeatures/index.js#L36-L39