Skip to content

Commit 866087a

Browse files
authored
refactor(useLockFn): catch to finally (#2421)
* refactor(useLockFn): catch to finally * refactor(useLockFn): keep the throw e
1 parent 15afaa6 commit 866087a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/hooks/src/useLockFn/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ function useLockFn<P extends any[] = any[], V = any>(fn: (...args: P) => Promise
99
lockRef.current = true;
1010
try {
1111
const ret = await fn(...args);
12-
lockRef.current = false;
1312
return ret;
1413
} catch (e) {
15-
lockRef.current = false;
1614
throw e;
15+
} finally {
16+
lockRef.current = false;
1717
}
1818
},
1919
[fn],

0 commit comments

Comments
 (0)