---
title: "Discussion on \"You shouldn't use an index as key of the element\" | Hashnode"
description: "Discussion on \"You shouldn't use an index as key of the element\". photo by ThisisEngineering RAEng on Unsplash\nLet me brief you about discussion, in React or any other stack when we need to present line of code with records of an array we use either foreach, map or for a loop. And when we do that it's good to have ..."
url: "https://hashnode.com/posts/you-shouldnt-use-an-index-as-key-of-the-element/5e96a0f43b68e66b1acbd649"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [You shouldn't use an index as key of the element](https://rajnishkatharotiya.hashnode.dev/you-shouldnt-use-an-index-as-key-of-the-element?utm_source=hashnode&utm_medium=feed)

photo by ThisisEngineering RAEng on Unsplash Let me brief you about discussion, in React or any other stack when we need to present line of code with records of an array we use either foreach, map or for a loop. And when we do that it's good to have ...

Apr 15, 2020 · rajnishkatharotiya.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#reactive-programming](https://hashnode.com/tag/reactive-programming)

## Written by

[Rajnish Katharotiya](https://hashnode.com/@rajnishkatharotiya)

@rajnishkatharotiya

  
[View profile](https://hashnode.com/@rajnishkatharotiya)

JavaScript enthusiast, Trying to learn everyday something new and share it to world before sleep via blog/vlog. 😎

## Responses 1

Markdown supported · ⌘↵ to post

[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}  />)
```
