When is an `id` undefined on a row of an `array` field?

default discord avatar
allanc
last month
3

Hi I've noticed that the

payload-types

generated for

array

fields always have an optional

id?: string

.



From what I've seen, ids are always automatically generated for array items. Is it safe to assume they will always be generated? And if not, when are they not generated?



I'm asking because I plan to do

key={option.id}

in my React front end



When is an

id

undefined on a row of an

array

field?

  • default discord avatar
    itsjxck
    last month

    I think it's so you can use the same type for type safe create. I could be wrong, but to me it's the only logical scenario when

    id

    would not exist

  • default discord avatar
    allanc
    last month

    Thanks for the reply @itsjxck, that makes a lot of sense and I think you're right

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.