-
Notifications
You must be signed in to change notification settings - Fork 731
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
fix: select option never use key in jsx declare usage #1889
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 706c90f:
|
<Select.Option label='3' value='2' key='abc'></Select.Option> | ||
<Select.Option label='2' value='3' key='efg'></Select.Option> | ||
<Select.Option label='4' value='5'></Select.Option> | ||
<Select.Option label='5' value='4'></Select.Option> |
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.
{ label: '1', value: '2', key: 'kkk' }, | ||
{ label: '2', value: '3', key: 'jjj' }, | ||
{ label: '3', value: '2' }, | ||
]}> |
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.
Passing run #2006 ↗︎
Details:
Review all test suite changes for PR #1889 ↗︎ |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #1889 +/- ##
==========================================
- Coverage 88.06% 88.03% -0.03%
==========================================
Files 436 436
Lines 25520 25522 +2
Branches 6440 6440
==========================================
- Hits 22473 22469 -4
- Misses 3047 3053 +6
☔ View full report in Codecov by Sentry. |
What kind of change does this PR introduce? (check at least one)
PR description
Select 使用 JSX 传入 Option时,Option的 key 未被收集,从而导致在 renderOption 列表时,总是走到兜底逻辑中去,在少数场景下,会导致react 抛出列表项 key 重复 的 warning
仅影响 JSX 传入 option 写法,若使用 props.optionList 传入后选项无该问题
需要区分 props.optionList 中带key,与 JSX 传入 option时带key两种情况。前者的key 在 onSelect、onChange回调入参里需要保留,后者不需要
Changelog
🇨🇳 Chinese
🇺🇸 English
Checklist
Other
Additional information