bunny
bunny

Reputation: 2037

Can two children with different parent have same keys in React

Can two children with different parent have same keys in React? For example, is it fine to have them in the same page?

<div key='parent1'>
  <div key='child1'></div>
  <div key='child2'></div>
</div>

<div key='parent2'>
  <div key='child1'></div>
  <div key='child2'></div>
</div>

Upvotes: 3

Views: 637

Answers (1)

Tanner Dolby
Tanner Dolby

Reputation: 4431

Yes from my understanding this is fine.

Keys only need to be unique between sibling elements, they don't need to be globally unique in your application. freeCodeCamp

Upvotes: 5

Related Questions