Skip to content

Table 组件 pagination 不设置 total 的情况下,onChange 死循环调用 #33487

@linkHe12

Description

@linkHe12
  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

使用 Table 组件的分页配置,且使用了 onChange,不设置 pagination 的 total 或 total 设置为 0,会导致 onChange 被执行,如果使用 Table 组件的组件调用了 setState,重新 render 后会导致死循环

Using the pagination configuration of the Table component and using onChange without setting the total of pagination or total to 0 will cause onChange to be executed, and if the component using the Table component calls setState, re-rendering will result in a infinity loop.

What is expected?

未设置 total 或 total 为 0 不会执行 onChange

What is actually happening?

未 total 或 total 为 0 执行了 onChange

Environment Info
antd 4.18.1
React 16.14.0
System macOS 12.0.1
Browser Chrome 96

问题产生是因为修复这个问题:#33411
在此处判断 current !> maxPage 就执行 onChange 导致的

mergedPagination.onChange?.(mergedPagination.current, mergedPagination?.pageSize!);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions