-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(space): add current key for Item #1395
base: master
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: f58c8dd The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Pull Request Test Coverage Report for Build 11323854846Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
packages/space/src/Component.tsx
Outdated
@@ -121,7 +121,7 @@ export const Space = forwardRef<HTMLDivElement, SpaceProps>((props, ref) => { | |||
<Item | |||
className={itemClassName} | |||
dividerClassName={styles.divider} | |||
key={`${itemClassName}-${i}`} | |||
key={(child as ReactElement).key} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import {isValidElement} from 'react';
key={isValidElement(child) ? child.key : `${itemClassName}-${i}`}
Опишите проблему
При использовании компонента Space, если удалить дочерний элемент, то все остальные элементы размонитруются и смонтируются заново, при условии что key никак не меняется при этом
Шаги для воспроизведения
Добавить в Space несколько элементов и после удалить первый
Пример можно посмотреть тут
https://codesandbox.io/s/infallible-water-27jjg5?file=/src/index.js
Ожидаемое поведение
Удалится первый элемент, остальные никак не среагируют на это
Чек лист