alibaba / alibaba/hooks

多次调用useRequest时,慢返回的请求会覆盖快返回的请求,如何解决?

Open
#2,624 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15k
Forks
2.8k
Avg merge
15h 7m
Merged PRs (30d)
2

Description

使用ahook的useRequest发请求,
比如列表查询 可能后端响应还没返回 用户切换了查询条件这种情况下需要能把之前请求cancel掉,以用户最后点击的查询条件发起的请求返回的结果为最后的结果

Contributor guide

Open the contributing guide

Research direction

Start with useRequest's request lifecycle and how it handles overlapping calls. Reproduce the case where a slow request follows a fast request after changing the query, then verify that only the latest query's result is applied and that the earlier request is cancelled or ignored. Add regression coverage for this ordering behavior.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.