Skip to content

Commit 381b669

Browse files
fix: react query invalidation (#2815)
1 parent bebcf46 commit 381b669

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

.changeset/brown-ears-jam.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+
Fix query invalidation when using react hooks

packages/thirdweb/src/react/core/providers/thirdweb-provider.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,25 @@ export function ThirdwebProvider(props: React.PropsWithChildren) {
4747
console.error("[Transaction Error]", e);
4848
})
4949
.then(() => {
50-
return queryClient.invalidateQueries({
51-
queryKey: [
52-
// invalidate any readContract queries for this chainId:contractAddress
53-
[
54-
"readContract",
55-
variables.__contract?.chain.id,
56-
variables.__contract?.address,
57-
] as const,
50+
return Promise.all([
51+
queryClient.invalidateQueries({
52+
queryKey:
53+
// invalidate any readContract queries for this chainId:contractAddress
54+
[
55+
"readContract",
56+
variables.__contract?.chain.id,
57+
variables.__contract?.address,
58+
] as const,
59+
}),
60+
queryClient.invalidateQueries({
5861
// invalidate any walletBalance queries for this chainId
5962
// TODO: add wallet address in here if we can get it somehow
60-
[
63+
queryKey: [
6164
"walletBalance",
6265
variables.__contract?.chain.id,
6366
] as const,
64-
],
65-
});
67+
}),
68+
]);
6669
});
6770
}
6871
}

0 commit comments

Comments
 (0)