Skip to content

Commit

Permalink
fix: useRequest plugin onFinally prevent after cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
brickspert committed Nov 23, 2021
1 parent ea9155a commit 277ebbf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/hooks/src/useRequest/src/Fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ export default class Fetch<TData, TParams extends any[]> {
this.runPluginHandler('onSuccess', res, params);

this.options.onFinally?.(params, res, undefined);
this.runPluginHandler('onFinally', params, res, undefined);

if (currentCount === this.count) {
this.runPluginHandler('onFinally', params, res, undefined);
}

return res;
} catch (error) {
Expand All @@ -111,7 +114,10 @@ export default class Fetch<TData, TParams extends any[]> {
this.runPluginHandler('onError', error, params);

this.options.onFinally?.(params, undefined, error);
this.runPluginHandler('onFinally', params, undefined, error);

if (currentCount === this.count) {
this.runPluginHandler('onFinally', params, undefined, error);
}

throw error;
}
Expand Down

0 comments on commit 277ebbf

Please sign in to comment.