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(list): fix error reported due to incorrect paginator parameters #39681
Conversation
Codecov ReportBase: 100.00% // Head: 100.00% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #39681 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 556 557 +1
Lines 9625 9626 +1
Branches 2722 2722
=========================================
+ Hits 9625 9626 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
components/list/index.tsx
Outdated
@@ -214,9 +236,9 @@ function List<T>({ | |||
|
|||
let splitDataSource = [...dataSource]; | |||
if (pagination) { | |||
if (dataSource.length > (paginationProps.current - 1) * paginationProps.pageSize) { | |||
if (dataSource.length > (paginationProps.current! - 1) * paginationProps.pageSize!) { |
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.
!
这里有点不合适吧, 如果 current 是确保有的, 就用不上!
, 如果可能没有, !
就是掩盖了.
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.
主要是 TS 类型推导会提示我错误, 原因是 extendsObject 的类型推导变了
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.
我感觉这里不应该这样解, 因为类似的应用场景应该很普遍. 🤔
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.
你是指这个 bug 的解决方案应该调整一下么? 还是 !
非空表达需要调整
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.
我仍然认为这个应该由业务处理, antd
不修复.
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.
这个问题确实比较有争议,但是我们现在能做的应该和 Table 的行为保持一致,先挂在这里吧~
components/_util/withDefaultProps.ts
Outdated
/* eslint-disable no-redeclare */ | ||
export function mergeProps<A, B>(a: A, b: B): B & A; | ||
export function mergeProps<A, B, C>(a: A, b: B, c: C): C & B & A; | ||
export function mergeProps(...list: any[]) { |
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.
建议直接把 extendObject 搬过来,或者就不用提了
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.
原来的 extendObject 类型推导貌似没有这个强,这里我是参考了 antd-mobile 的 utils。
如果仍然需要调整,我可以直接把 extendObject 原封不动移动到 _utils/extendObject.ts
中
104a917
to
2689aff
Compare
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
fix #39496
💡 Background and solution
📝 Changelog
pagination.pageSize
is undefined.☑️ Self-Check before Merge