Two children with the same key in React

See this for more understanding in "key" related warnings and best practices

 function ListItem(props) {
  // Correct! There is no need to specify the key here:
  return <li>{props.value}</li>;

function NumberList(props) {
  const numbers = props.numbers;
  const listItems = =>
    // Correct! Key should be specified inside the array.
    <ListItem key={number.toString()}
              value={number} />

  return (

const numbers = [1, 2, 3, 4, 5];
  <NumberList numbers={numbers} />,

Visit this link for more information

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 duplicated.

You are passing element not index. And if your element is same then the error is being thrown. To pass the index use second param:

.map((element, index)=>

Now, using index will give you different key.