-1

Hi everyone I would like to display for each element all of its sub-documents.

  <div><ul>{designModdulles.map((designModdulle)=><li key={designModdulle.epreuves.nature_epreuve}>{designModdulle.epreuves.nature_epreuve}</li>) }</ul></div>
```
I wanted the sub documents to be displayed` in a map
but i had: Warning: Each child in a list should have a unique "key" prop.
Mouni19
  • 1
  • 1

3 Answers3

0

Assuming this is JavaScript, the cause of the issue is that there are duplicate key values. You can use the index of each map entry to create a new key

<div><ul>{designModdulles.map((designModdulle, index)=><li key={designModdulle.epreuves.nature_epreuve + index}>{designModdulle.epreuves.nature_epreuve}</li>) }</ul></div>

You may want to look at the following to see what your choices are (there are other resources as well): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

ChrisSc
  • 276
  • 2
  • 9
  • It may be that there are no values in `designModdulle.epreuves.nature_epreuve`, or there's an empty string. A missing value would also explain why the key warning was occurring. – ChrisSc Nov 13 '22 at 18:03