-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Latest wagmi
and @tanstack/react-query
are not compatible with StructuralSharing
(breaks dev)
#4233
Comments
Can confirm this is happening out of the box and with custom |
+1 for this issue. looks like a |
- rewrite balance hook to avoid structuralSharing error (wevm/wagmi#4233) - use starknet price instead of ethereum for starknet balance in usd
Workaround: Modify default https://wagmi.sh/react/getting-started#setup-tanstack-query import { QueryClient } from '@tanstack/react-query';
import { structuralSharing } from '@wagmi/core/query';
const queryClient = new QueryClient({
defaultOptions: {
queries: {
structuralSharing,
},
},
}); |
I opened a PR to fix this upstream in React Query: TanStack/query#8030 |
Fixed https://github.com/TanStack/query/releases/tag/v5.55.3 – please update to |
- rewrite balance hook to avoid structuralSharing error (wevm/wagmi#4233) - use starknet price instead of ethereum for starknet balance in usd
Thank you so much :-D! |
This issue has been locked since it has been closed for more than 14 days. If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Wagmi version. If you have any questions or comments you can create a new discussion thread. |
Check existing issues
Describe the bug
Wagmi enables
StructuralSharing
by default, however creating a new project right with latest wagmi and tanstack query does not work, breaks all queries in dev that include any BigInt. Every query that includes a BigInt (including native ones) returns an error.The only way to fix it is by disabling
structuralSharing
explicitly and globally.Link to Minimal Reproducible Example
https://stackblitz.com/edit/new-wagmi-d1zd7f?file=src%2Fmain.tsx,src%2FBalanceAtom.tsx
Steps To Reproduce
Just look at console logs. And look at the
balanceData
output for the error from query.The error looks like:
StructuralSharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [["balance",{"address":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","chainId":1}]]: TypeError: Do not know how to serialize a BigInt
This is even after enabling custom
hashFn
included inwagmi/query
.What Wagmi package(s) are you using?
wagmi
Wagmi Package(s) Version(s)
2.12.8
Viem Version
2.21.1
TypeScript Version
5.5.4
Anything else?
No response
The text was updated successfully, but these errors were encountered: