You can pass another parameter within your map function like so:
this.state.elements.map((element, index) => {
return <span style={element.myStyle} key={index} >{element}</span>;
});
The second parameter of the Array.prototype.map
function actually contains the current index of the particular element in that array.
This way, you'll be sure that your key is not…
Top comments (0)