Skip to content

Commit c953c3f

Browse files
authored
feat(react): add enabled param to useWalletBalance hook (#4032)
1 parent 1a71de0 commit c953c3f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.changeset/yellow-numbers-yell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Added `enabled` param to `useWalletBalance` hook

packages/thirdweb/src/react/core/hooks/others/useWalletBalance.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type UseWalletBalanceOptions = Prettify<
1919
>;
2020
export type UseWalletBalanceQueryOptions = Omit<
2121
UseQueryOptions<GetWalletBalanceResult>,
22-
"queryFn" | "queryKey" | "enabled"
22+
"queryFn" | "queryKey"
2323
>;
2424

2525
/**
@@ -85,6 +85,10 @@ export function useWalletBalance(
8585
tokenAddress,
8686
});
8787
},
88-
enabled: !!chain && !!client && !!address,
88+
enabled:
89+
(queryOptions?.enabled === undefined || queryOptions.enabled) &&
90+
!!chain &&
91+
!!client &&
92+
!!address,
8993
});
9094
}

0 commit comments

Comments
 (0)