---
title: "Comment by fengxh on \"You shouldn't use an index as key of the element\" | Hashnode"
description: "It is exactly the problem. I always pass the id or code field as key in React/Vue. shortedRow.map( data =&gt; &lt;Component key={ data .id} /&gt;)"
url: "https://hashnode.com/posts/you-shouldnt-use-an-index-as-key-of-the-element/5e96a0f43b68e66b1acbd649/comment/5e98223fa12c7e6a1a6af8e8"
---

[Discussion](https://hashnode.com/posts/you-shouldnt-use-an-index-as-key-of-the-element/5e96a0f43b68e66b1acbd649)

Comment [You shouldn't use an index as key of the element](https://hashnode.com/posts/you-shouldnt-use-an-index-as-key-of-the-element/5e96a0f43b68e66b1acbd649)

[fengxh](https://hashnode.com/@fengxh)

[Apr 16, 2020](https://hashnode.com/posts/you-shouldnt-use-an-index-as-key-of-the-element/5e96a0f43b68e66b1acbd649/comment/5e98223fa12c7e6a1a6af8e8)

It is exactly the problem. I always pass the id or code field as key in React/Vue.

```
shortedRow.map(data => <Component key={data.id}  />)
```
