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

Reactive vars stop broadcasting changes to cache when query became inactive and active again (e.g. via navigation) #7593

Closed
WojciechKulpa opened this issue Jan 19, 2021 · 4 comments · Fixed by #7657

Comments

@WojciechKulpa
Copy link

Intended outcome:
Changes made to local state managed with reactive variables should trigger update on every active query that depends on that variable. No matter if that was previously deactivated.

Actual outcome:
If query was deactivated and activated again update notification is no longer triggered.

How to reproduce the issue:
CodeSandbox

  1. Click button "Click to increment" several times - change notification is broadcasted and component is re-rendered with good counter.
  2. navigate to "About" and go back to "Home"
  3. Click button again several times - no update
  4. If we now navigate again to "About" and back to "Home" all works good again and in fact we are back at step one.

Based on my research I see that when query is deactivated cache is detached from reactive variable (forgetCache) but when it is activated again cache is not attached again as it is done in initial render or after second navigation.

P.S. That works good if we are using useReactiveVar hook.

Versions
reproduced with: 3.3.6, 3.3.7

@benjamn
Copy link
Member

benjamn commented Jan 19, 2021

@WojciechKulpa Thanks for the reproduction. I'll take a look at this soon (this week).

@lassesteffen
Copy link

Any updates on this? We are facing the same issue and are looking forward to a fix for that! :)

@jcreighton
Copy link
Contributor

@benjamn Cool if I re-assign this to myself? There's another issue related to reactive vars (#7609) that I'm going to look into, so might as well look into this too.

@benjamn
Copy link
Member

benjamn commented Feb 5, 2021

@WojciechKulpa Thanks to your reproduction, I can confirm that this is fixed in @apollo/client@3.3.8 (just published).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants