-
-
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
[bug] useContractRead not returning key/value pairs after second page refresh #460
Comments
Adding a link to the repo and the demo app. Demo app: https://screech.vercel.app/ Repo with line of code in question: https://github.com/zawilliams/screech/blob/main/hooks/useScreech.js#L20 If you view the console on the page upon first load you should see an array logged a few times, but if you refresh the page, the key/value pairs inside the array disappear. You have to reload the page in an incognito window to see it happen again. |
@zawilliams thanks for providing all this info! can you put together an example that is more minimal? will make it much easier to check this out. |
@tmm no prob! Here's a minimal example: https://codesandbox.io/s/ethers-vs-wagmi-d6tq9z?file=/src/App.tsx Pull up the browser console (not the codesandbox console on the page) and once this loads, you'll see |
@tmm had time to dig into this more. It looks like this is related to caching and serializing. If after the second refresh, you delete the This is where the cache is created for Will have more time to dig in again later. Maybe it's an issue with the serializer? |
Upon looking at the cached data in |
Thank you for looking into this. Raised a PR for a fix #552. |
@jxom glad to help! Thanks for raising the PR! |
@jxom @tmm I've updated my CodeSandbox (https://codesandbox.io/s/ethers-vs-wagmi-d6tq9z?file=/src/App.tsx) to use the new release (0.4.10) after the PR was merged for this issue, but it seems it has not fixed the issue. If you pull up the console, you'll see this now: Note the new 3rd array key/value pair (null: Array). Previously this was just 2 arrays without the missing key/value pairs that Ethers returns correctly. Again, here's what Ethers returns, and I assume Should I raise a new issue or can this issue be re-opened? |
Fixing here |
@jxom thanks for the fix! Working nicely now 🎉 |
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 other comments you can create a new discussion. |
Is there an existing issue for this?
Package Version
0.3.5
Current Behavior
Hey all,
I was using
useContractWrite
to write something to my local Hardhat, and then refreshed the page which triggersuseContractRead
and noticed that first refresh I get the following (note the key/value pairs):And then I refresh the page again, and I get this (no key/value pairs) in the console:
Is there something obvious I'm missing as to why the key/value pairs disappear after a couple refreshes when I'm returning an array of structs? Or is this a bug?
Also not sure if this is an
ethers
issue or if it's awagmi
issue.Expected Behavior
The expected behavior is for it to return the struct with key/value pairs like so:
Steps To Reproduce
No response
Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: