Skip to content

Commit eb1cf6e

Browse files
committed
feat: support component
1 parent 485ccac commit eb1cf6e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/hooks/src/useRequest/component-use/UseRequest.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
UseRequestOptions,
66
UseRequestPlugin,
77
} from "../types";
8+
import { isEqual } from "lodash-es";
89

910
// 泛型工厂
1011
function createUseRequestQueryComponent<TData = any, TParams extends unknown[] = any[]>() {
@@ -69,10 +70,13 @@ function createUseRequestQueryComponent<TData = any, TParams extends unknown[] =
6970

7071
watch(
7172
refreshDeps,
72-
() => {
73+
(newVal, oldVal) => {
74+
// 如果 refreshDeps 没有变化,则不刷新
75+
// 这里对比的是数组,所以需要使用 isEqual 来对比
76+
if (isEqual(newVal, oldVal)) return;
7377
result.refresh();
7478
},
75-
{ immediate: true, deep: true }
79+
{ immediate: true }
7680
);
7781

7882
return () => {

0 commit comments

Comments
 (0)