Skip to content

Commit

Permalink
Merge pull request #4731 from sgadman/multi-value-key
Browse files Browse the repository at this point in the history
MultiValue key - made more unique by adding a hyphen
  • Loading branch information
JedWatson committed Sep 3, 2021
2 parents ed15c73 + 59cdba8 commit 117d4bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gold-tomatoes-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-select': patch
---

MultiValue key now includes a hyphen between the value and the index to prevent edge cases where you could get a duplicate key error
2 changes: 1 addition & 1 deletion packages/react-select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,7 @@ export default class Select<
}}
isFocused={isOptionFocused}
isDisabled={isDisabled}
key={`${this.getOptionValue(opt)}${index}`}
key={`${this.getOptionValue(opt)}-${index}`}
index={index}
removeProps={{
onClick: () => this.removeValue(opt),
Expand Down

0 comments on commit 117d4bb

Please sign in to comment.