[STK-247][FIX] - Network switching bug #194
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: STK-247
Context
Long story short: I couldn't find why some of our context chainId changes do not trigger the effect that fetches the balances for a connected wallet. The chainId value changes correctly, but this doesn't trigger the effect sometimes.
Some of the reasons for a value change in the effect dependency array not triggering the effect execution:
So, all-in-all, values present in the dependency array do not guarantee the effect to trigger when these change. If there are other reasons for this to happen (most likely there are) I couldn't find them.
I propose this solution because it's simple and seems to fix the issue, but please check it and speak out your opinion because I'm not 100% convinced about it. As far as I could check, this happens just for token balances fetch. I also tried aborting ongoing fetch values (with the Abort Controller pattern) and a bunch of other stuff with no success.
Description
Visual Evidence
https://www.loom.com/share/d49d6b37a5d2463ea1222dce3308780d?sid=e43f11f9-587e-4f86-b0da-0a92924afb6e