ant-design / ant-design/pro-components

🐛[BUG] pro-table一直处于loading状态

Open
#7,902 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.8k
Forks
1.4k
Avg merge
10h 44m
Merged PRs (30d)
3

Description

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

### 🐛 bug 描述
基于某些原因,希望table处于loading状态的时候,搜索或者刷新这些操作都不可用,所以需要隐藏table内部的loading图标,将遮罩的范围扩大到整个表格。但在将loading设置为false以后,发现由request触发的onLoadingChange只会执行一次,导致数据即使加载完了表格也一直处于loadig的状态

### 📷 复现步骤

将pro-components版本调整到2.3.40或者将pro-table版本调整到3.2.2或者这两个的后续版本,引入proTable组件即可复现
### 🏞 期望结果

期望在数据加载结束的时候结束loading状态
### 💻 复现代码

https://codesandbox.io/s/protable-spin-rlg6gy?file=/App.tsx
### © 版本信息

- ProComponents 版本: [2.3.40]
- ProTable版本:[3.2.2]
- umi 版本
- 浏览器环境:Chrome118
- 开发环境 [windowS]

### 🚑 其他信息

发现同一个问题https://github.com/ant-design/pro-components/issues/4390
研究了下发现还是useMergeState的变更引起的
https://github.com/react-component/util/blob/v5.24.4/src/hooks/useMergedState.ts
https://github.com/react-component/util/blob/v5.38.1/src/hooks/useMergedState.ts
```
//5.38.1
useLayoutUpdateEffect(() => {
const prev = prevValue[0];
if (innerValue !== prev) {
onChangeFn(innerValue, prev);
}
}, [prevValue]);
//5.24.4
useLayoutEffect(() => {
const [current, source, prev] = mergedValue;
if (current !== prev && source === Source.INNER) {
onChangeFn(current, prev);
changeEventPrevRef.current = prev;
}
}, [mergedValue]);
```

Contributor guide

Open the contributing guide

Research direction

Start with the App.tsx reproduction in the linked CodeSandbox and verify the behavior with ProComponents 2.3.40 or ProTable 3.2.2. Read the ProTable loading and request flow, then compare the referenced useMergedState versions in react-component/util. Done means loading ends after the request completes and the loading-change behavior matches the expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.