Open
Description
interface Dog {
id?: string;
name: string;
}
const dogs: Dog[] = [
{ id: "spikey", name: "spike" },
{ name: "spot" },
] as const;
export const Dogs = () => (
<div>
{dogs.map((dog) => (
<div key={dog.id}>{dog.name}</div>
))}
</div>
);
The above code does not currently violate jsx-key. With type information it could, and I believe it really should. Something that can potentially be undefined is unsuitable as a key.
Metadata
Metadata
Assignees
Labels
No labels