Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

useControllableValue 的第一个参数,假如是null会直接报错 #2630

Closed
mmmml-zhao opened this issue Aug 23, 2024 · 1 comment
Closed

Comments

@mmmml-zhao
Copy link
Contributor

mmmml-zhao commented Aug 23, 2024

背景:
在封装antd的table的rowSelection字段,该字段传 undefined || null 时 ,不显示 勾选,传对象(包括空对象)需要显示勾选。
准备用useControllableValue 控制 selectedRowKeys / onChange。
然后rowSelection传了null,发现这个hook报错了。

疑惑

  1. 有点想知道 useControllableValue 不限制第一个值传null这个逻辑的思考
  2. 需要ts限制一下第一个值不能传null吗

就感觉这个改也行(毕竟现在传null报错),不改也行(貌似是我使用逻辑问题,第一个要不传undefined 或者给个真的对象)。
image

@crazylxr
Copy link
Collaborator

第一点:确实应该处理一下,这个没做保护,欢迎 pr
第二点:ts 类型是限制了不能传 null 的,但是只是类型上限制了,你实际传了 null,也没办法。

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

No branches or pull requests

2 participants