Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

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

default discord avatar
allannnc2 years ago
2

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
    itsjxck2 years ago

    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
    allannnc2 years ago

    Thanks for the reply

    @93699784942034944

    , that makes a lot of sense and I think you're right

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.