1

I don't think so, but just in case, does anyone know the answer and have a source?

When we map an array to React elements it's a good practice to add a key prop to each element (React will even warn you when you don't).

That's because it helps React know which element to update/remove when the array changes.

But in the case of React Server Components, since it's only rendered once in the server, is it still necessary?

UPDATE

I'm starting to think it's actually necessary. After upgrading to the latest Next and React versions I started getting this error:

Uncaught Error: Cannot access XXX.prototype on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.

And XXX is the name of a component that I'm mapping to.

These error went away as soon as I added the key prop to them.

gfpacheco
  • 2,831
  • 2
  • 33
  • 50

0 Answers0