react-component / react-component/table
虚拟滚动时,table getRowKey 索引index 为undefined
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 618
- Avg merge
- 10h 19m
- Merged PRs (30d)
- 2
Description
使用虚拟滚动时,设置rowKey有个特殊处理,当唯一值id不存在时,使用索引index代替
rowKey = {(record, index)=>(record?.id || index )}
但索引打印为undefined
看了是因为虚拟滚动Table内部使用rc-virtual-list组件时未传递index,建议支持下索引,或者直接在Table rowKey移除对index的支持,否则使用时容易出现bug
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at src/VirtualTable/BodyGrid.tsx around the linked line and trace how rc-virtual-list supplies row data to Table's rowKey callback. Reproduce virtual scrolling with a rowKey that falls back to index, then verify the chosen behavior: the index is available to rowKey or index-based rowKey support is removed. There are no named tests in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100