You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/hooks/src/useRequest/doc/basic/basic.en-US.md
+9-5Lines changed: 9 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,12 +97,16 @@ We have modified the user name, but we do not want to wait for the request to be
97
97
98
98
<!-- <code src="./demo/formatResult.tsx" /> -->
99
99
100
-
## Cancel request
100
+
## Cancel response
101
101
102
-
`useRequest` provides a `cancel` function, which can cancel the request. At the same time, `useRequest` will automatically cancel the current request at the following timing:
102
+
`useRequest` provides a `cancel` function, which will **ignore** the data and erros returned by the current promise
103
103
104
-
- When the component is unmounting, the ongoing request will be cancelled
105
-
- Race cancellation, when the previous request has not returned, if the next request is initiated, the previous request will be cancelled
104
+
**Note: Calling `cancel` doesn't cancel the execution of promise**
105
+
106
+
At the same time, `useRequest` will automatically ignore the response at the following timing:
107
+
108
+
- When the component is unmounting, the ongoing promise
109
+
- Race cancellation, when the previous promise has not returned, if the next promise is initiated, the previous promise will be ignored
106
110
107
111
<codesrc="./demo/cancel.tsx" />
108
112
@@ -154,7 +158,7 @@ const {
154
158
| refresh | Use the last params, call `run` again |`() => void`|
155
159
| refreshAsync | Use the last params, call `runAsync` again |`() => Promise<TData>`|
0 commit comments