Skip to content

Commit 278b117

Browse files
wo-o29kimyouknow
andauthored
refactor(Separated): fix key usage in Separated component: use child.key instead of array index for better stability (toss#278)
Co-authored-by: 김윤호 yunho <kimyouknow@naver.com>
1 parent fa46f3d commit 278b117

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

.changeset/late-zoos-join.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-simplikit': patch
3+
---
4+
5+
fix: Replace array index keys with child keys in Separated

packages/core/src/components/Separated/Separated.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function Separated({ children, by: separator }: Props) {
3939
return (
4040
<>
4141
{childrenArray.map((child, i, { length }) => (
42-
<Fragment key={i}>
42+
<Fragment key={child.key ?? i}>
4343
{child}
4444
{i + 1 !== length && separator}
4545
</Fragment>

0 commit comments

Comments
 (0)