-
-
Notifications
You must be signed in to change notification settings - Fork 142
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
CascaderProps 重构 #480
CascaderProps 重构 #480
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #480 +/- ##
=======================================
Coverage 99.66% 99.67%
=======================================
Files 23 23
Lines 604 611 +7
Branches 182 186 +4
=======================================
+ Hits 602 609 +7
Misses 2 2 ☔ View full report in Codecov by Sentry. |
Cascader 泛型优化,解决了 options + filedNames + value + onChange params Value 的类型检测不爽的问题
遗留问题:
一、由于
checkable
有ReactNode
类型,所以区分是否多选类型不完美,如下 5 种场景,会有 2 个 onChange value 为 any 类型,不过在 antd 没有此问题,antd 的 multiple 是 boolean 类型PS:支持
ReactNode
也没什么历史背景,就是初设计就加上了类型 #184 导致没法去掉了04-10 进展
给 CascaderProps 增加 Multiple 泛型,用来判断是否是多选,可完美解决 ReactNode 检测不健壮问题,以及 onChange 方法需要使用 2 个类型:单选
SingleCascaderProps['onChange']
多选MultipleCascaderProps['onChange']
遗留问题:
由于 Value 泛型在 OptionType 泛型后面,所以当传了 value 没传 options,那 onChange 的 value 会是
DefaultOptionType['value']
类型