DEV Community

Max Angelo Perin (ᜋᜃᜐ)
Max Angelo Perin (ᜋᜃᜐ)

Posted on

Answer: Two children with the same key in React [duplicate]

You can pass another parameter within your map function like so:, index) => {
   return <span style={element.myStyle} key={index} >{element}</span>;

The second parameter of the function actually contains the current index of the particular element in that array.

This way, you'll be sure that your key is not…

Discussion (0)