#How can I bypass unique key props

17 messages · Page 1 of 1 (latest)

sage obsidian
#

either do what is it saying or disable this eslint rule

#

you may still get the error in console

lament lantern
#

if you choose to ignore this error there will be negative implications since react relies on key prop for its rendering logic

#

by default react will use the index for the key prop, even if you don't provide one

#

but if the order of your list ever changes you may not see the expected results when rerendering if you rely on index as a key

#

I see you already have an item.id in your code, instead of ignoring the error it's probably a lot safer to just resolve it

magic oak
lament lantern
#

Your code above is doing it correctly

#

If it says there’s a duplicate key then there is a duplicate key

#

The keys usually come from database generated ids

magic oak
#

I still have next-dev.js?3515:20 Warning: Each child in a list should have a unique "key" prop.

lament lantern
#

Console log your keys

#

See if there is a a duplicate

magic oak
#

its logging twice

#

oh i see now its the backend thats also logging

#

well ID should work but it dosnt

magic oak