I have read in React docs that keys are not globally unique and that they should be unique per siblings, but why does this code work?
import React from 'react'
import ReactDOM from 'react-dom'
const people = [
{name: 'John', age: 20},
{name: 'Danny', age: 35},
{name: 'Rebecca', age: 18},
]
const element = (
<ul>
{people.map((person, index) => (
<li key={index}>{person.name}</li>
))}
{people.map((person, index) => (
<li key={index}>{person.name}</li>
))}
</ul>
)
ReactDOM.render(
element,
document.getElementById("root")
)
Aren't all of the resultant <li> elements considered siblings, so why I do not get any warning that there are two elements with the same key?