8000 fix(table): sortConfig值为undefined时与默认值{}不一致,会导致翻页时再次触发request请求 by caronchen · Pull Request #7616 · ant-design/pro-components · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(table): sortConfig值为undefined时与默认值{}不一致,会导致翻页时再次触发request请求 #7616

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

Merged
merged 1 commit into from
Sep 2, 2023

Conversation

caronchen
Copy link
Contributor

具体表现:

  1. 假设:请求数据100条,总数100条,每页5条;(预期本地翻页)
  2. 初始通过request请求服务端数据100条;
  3. 点击第2页,预期本地翻页,但实际发起了request请求 因此列表始终会有两次request请求。

原因:
setProSort(sortConfig)时,sortConfig值为undefined,与原初始值{}不相同,触发effect,从而发起了request请求。

具体表现:
1. 假设:请求数据100条,总数100条,每页5条;(预期本地翻页)
2. 初始通过request请求服务端数据100条;
3. 点击第2页,预期本地翻页,但实际发起了request请求
因此列表始终会有两次request请求。

原因:
setProSort(sortConfig)时,sortConfig值为undefined,与原初始值{}不相同,触发effect,从而发起了request请求。
@github-actions
Copy link
github-actions bot commented Sep 1, 2023

😭 Deploy PR Preview failed.

@caronchen
Copy link
Contributor Author

具体表现:

  1. 假设:请求数据100条,总数100条,每页5条;(预期本地翻页)
  2. 初始通过request请求服务端数据100条;
  3. 点击第2页,预期本地翻页,但实际发起了request请求 因此列表始终会有两次request请求。

原因: setProSort(sortConfig)时,sortConfig值为undefined,与原初始值{}不相同,触发effect,从而发起了request请求。

目前使用上规避的方式是至少指定一个列使用排序,如下:
{
...,
sorter: true,
defaultSortOrder: 'descend'
}

@codecov
Copy link
codecov bot commented Sep 1, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (af12bf3) 98.10% compared to head (e0b3a9c) 98.10%.
Report is 4 commits behind head on master.

❗ Current head e0b3a9c differs from pull request most recent head b2cc768. Consider uploading reports for the commit b2cc768 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7616   +/-   ##
=======================================
  Coverage   98.10%   98.10%           
=======================================
  Files         344      344           
  Lines       11496    11500    +4     
  Branches     4321     4328    +7     
=======================================
+ Hits        11278    11282    +4     
  Misses        180      180           
  Partials       38       38           
Files Changed Coverage Δ
packages/form/src/components/List/index.tsx 100.00% <ø> (ø)
packages/form/src/components/List/style.ts 100.00% <ø> (ø)
...ages/layout/src/components/SiderMenu/style/menu.ts 100.00% <ø> (ø)
...kages/layout/src/components/SiderMenu/BaseMenu.tsx 92.60% <100.00%> (+0.13%) ⬆️
packages/table/src/Table.tsx 98.34% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chenshuai2144 chenshuai2144 changed the title fix: sortConfig值为undefined时与默认值{}不一致,会导致翻页时再次触发request请求 fix(table): sortConfig值为undefined时与默认值{}不一致,会导致翻页时再次触发request请求 Sep 2, 2023
@chenshuai2144 chenshuai2144 merged commit c51be62 into ant-design:master Sep 2, 2023
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

Successfully merging this pull request may close these issues.

2 participants
0