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

useSubscription return old value when router.push is used #187

Closed
hipertracker opened this issue Jan 20, 2023 · 1 comment
Closed

useSubscription return old value when router.push is used #187

hipertracker opened this issue Jan 20, 2023 · 1 comment

Comments

@hipertracker
Copy link

I have Vue2.7 with composition API, Vuetify 2 and Villus. This is SPA and I have a page content changed by the URL "id".

Step 1. I open the page1. It contains useSubscription and it returns correct data from GraphQL server.
Step 2. I move to page2 with Vue router push method. This time subscription is returning the last data (from page 1)
Step 3. I move to page3 with the same router push method. Now I can see the last data from page 2! The result is always one behind...

When I move between pages with hard page reload all works as excepted. When I do this with javascript and HTML Push method the graphql subscription always returns the data from the last call. I use policy: network-only.

Any hints?

@hipertracker
Copy link
Author

hipertracker commented Jan 20, 2023

This was not Villus's issue. I got the same error in the Apollo client. The solution was to add a "key" prop to the component (<MyComponen :key="id"/>) which forced Vue to re-render the component. There is a great article about it https://michaelnthiessen.com/force-re-render/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant