Skip to content
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] useContractReads data instability #648

Closed
1 task done
matthewlilley opened this issue Jul 1, 2022 · 6 comments · Fixed by #659
Closed
1 task done

[bug] useContractReads data instability #648

matthewlilley opened this issue Jul 1, 2022 · 6 comments · Fixed by #659

Comments

@matthewlilley
Copy link

matthewlilley commented Jul 1, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

latest

Current Behavior

useContractReads returns unstable data, equality is always lost despite underlying data being exactly the same

Expected Behavior

In cases where the underlying data has not changed, for equality to be preserved.

Steps To Reproduce

repro below

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

https://codesandbox.io/s/small-smoke-2i7b0q?file=/src/App.js

@tmm
Copy link
Member

tmm commented Jul 2, 2022

Off chance this might be related TanStack/query#3772

@matthewlilley
Copy link
Author

Might be useful to look at for this one: https://github.com/Uniswap/redux-multicall/blob/main/src/hooks.ts#L55

@jxom
Copy link
Member

jxom commented Jul 4, 2022

Opened a fix here: #659.

React Query's data comparison function does not support the ethers Result type as it is not JSON serializable. I have added an isDataEqual flag that defaults to our implementation of deepEqual (RQ also does a deep equal implementation for their structural sharing), but you can also provide your own (like you did here)! What do you think?

@matthewlilley
Copy link
Author

Result

That makes sense, feels like this would be a valuable PR to ethers too now I think about it. I wonder if the same is true for ethers v6. Yeah, it seems this would work, but would like to test if you'd put up a pre-release version. I'd be happy to do that if you can.

@jxom jxom closed this as completed in #659 Jul 5, 2022
@jxom
Copy link
Member

jxom commented Jul 5, 2022

@matthewlilley – can you check 0.5.7?

Copy link
Contributor

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.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants