Skip to content
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

[Table] EnhancedTable组件中,使用tree结构,data属性的某一项数据无rowKey(undefined) 就报错白屏,未做空判断 #2395

Closed
jiangxin829 opened this issue Jul 27, 2023 · 4 comments
Assignees

Comments

@jiangxin829
Copy link

tdesign-react 版本

1.1.16

重现链接

https://codesandbox.io/s/tdesign-react-demo-forked-28ggps?file=/src/demo.jsx:1001-1163

重现步骤

demo中第26行rowKey不传时(为undefined)即可复现

期望结果

兼容rowKey为undefined的场景不报错,数据来源经常是api,数据不可控,前端不应该做这个兼容,UI库做才合理

实际结果

image

框架版本

No response

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response

@github-actions
Copy link
Contributor

👋 @jiangxin829,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@jiangxin829 jiangxin829 changed the title EnhancedTable组件中,使用tree结构,data属性的某一项数据无rowKey(undefined) 就报错白屏 EnhancedTable组件中,使用tree结构,data属性的某一项数据无rowKey(undefined) 就报错白屏,未做空判断 Jul 27, 2023
@uyarn uyarn changed the title EnhancedTable组件中,使用tree结构,data属性的某一项数据无rowKey(undefined) 就报错白屏,未做空判断 [Table] EnhancedTable组件中,使用tree结构,data属性的某一项数据无rowKey(undefined) 就报错白屏,未做空判断 Jul 28, 2023
@github-actions
Copy link
Contributor

♥️ 有劳 @yunfeic @tengcaifeng @Yacent @basecss 尽快确认问题。
确认有效后将下一步计划和可能需要的时间回复给 @jiangxin829

@chaishi
Copy link
Collaborator

chaishi commented Aug 27, 2023

前端不应该做这个兼容,UI库做才合理

十分抱歉,不太认同这样的结论。

如果只有 UI 库做这样的兼容,不抛出错误,那么就会认为不存在行唯一标识也是合理的。
但是其实,缺少行唯一标识是非常不合理的数据,比如:在行展开功能、行选中功能、树形节点展开功能中,都会因为缺少行唯一标识导致组件无法识别 应该展开哪一个行,展开哪一个节点,又选中哪一个节点,如此,便是一乱到底了。而此时,如果控制台没有抛出明确地错误提醒,则会非常难以排查问题所在。到时候就会出现另一个 issue “EnhanceTable 无法正常选中节点,无法正常展开节点...” 等等

综上,个人认为,这类缺少重要信息的数据,应当在组件外层处理,而非 UI 组件内部。故而 issue close

@chaishi chaishi closed this as completed Aug 27, 2023
@jiangxin829
Copy link
Author

@chaishi
可能理解有差异,我也认同缺少rowKey等重要信息的数据在外层处理,而且UI库也不应该忽略错误,控制台提示error很ok。但是这里看起来是UI组件内部没有处理错误,导致浏览器页面白屏。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants