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

useSuspenseQuery is not refreshing the data #76

Open
Kostanos opened this issue Jul 16, 2022 · 4 comments
Open

useSuspenseQuery is not refreshing the data #76

Kostanos opened this issue Jul 16, 2022 · 4 comments

Comments

@Kostanos
Copy link

Hey, I found the issue with useSuspenseQuery, and I can't find a workaround for it yet, can you please help?

When I use useSuspenseQuery, everything works as expected when user navigates from another views,
but, if user navigates to the same view with different set of parameters, the useSuspenseQuery actually triggers the query, but do not update the data variable.

navigate from Home to Listing view:

const { data, loading, loaded } = useSuspenseQuery(query, variables);

 render   |  loading  |  loaded   | data
-------------------------------------------
   1      |  false    |   true   | {data}     - expected, very good, even loading=true was skipped

navigate from Listing to Listing with different variables, example page=2 or query="some search"

 render   |  loading  |  loaded   | data
-------------------------------------------
   1      |  false    |   true    | {data}     - the data variable has the old data yet. Despite the query was triggered in networking, and it has a new data arrived.

The data is never refreshed with a new array that came from the server.
Is user navigates away from the view and come back, the data refreshes as expected.

PS. I use const navigate = useNavigate(); navigate('new path'); for the navigation

@arackaf
Copy link
Owner

arackaf commented Jul 18, 2022

Hey thanks for the issue. I'm using this hook in my own web app, and it should absolutely re-trigger the query, and refresh the results when the query variables change.

If you could put together a repro on StackBlitz (or wherever, but Stack Blitz is probably the best option) I'd be happy to look into it.

https://stackblitz.com/

@arackaf
Copy link
Owner

arackaf commented Jul 18, 2022

@Kostanos Looking at the source for useSuspenseQuery ... the best I can think of is that maybe you're setting the active option?

@Kostanos
Copy link
Author

Hey, no, I'm not using the active variable in this case. And as I mentioned, the query itself was sent to the server (with active=false, the query will not be send), and has a updated result. But the data variable is not updated.
I'll try to set up Stack Blitz later. Very tight now with one project.

@arackaf
Copy link
Owner

arackaf commented Jul 19, 2022

Ah yeah - you did say that. That's really crazy. Hope you can get a repro - eager to see what this is.

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

2 participants