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

useQuery not updating loading state #6253

Closed
samrith-s opened this issue May 7, 2020 · 4 comments
Closed

useQuery not updating loading state #6253

samrith-s opened this issue May 7, 2020 · 4 comments
Milestone

Comments

@samrith-s
Copy link

Intended outcome:

const { data, loading, error } = useQuery(HELLO_WORLD_QUERY);

Once the query is complete it loading should be false.

Actual outcome:

The loading state is always true. This results in the page loading infinitely.

How to reproduce the issue:

  • Add any query.
  • Use useQuery from @apollo/client@^3.0.0-beta.44.
  • Log loading.

Versions

System:

  • OS: macOS Mojave 10.14.5

Binaries:

  • Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
  • Yarn: 1.22.4 - ~/Work/troup/client/node_modules/.bin/yarn
  • npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm

Browsers:

  • Edge: 81.0.416.68
  • Safari: 12.1.1

npmPackages:

  • @apollo/client: ^3.0.0-beta.44 => 3.0.0-beta.44
  • apollo: ^2.27.3 => 2.27.3
  • apollo-client: ^2.6.8 => 2.6.8
  • react-apollo: ^3.1.5 => 3.1.5
@benjamn
Copy link
Member

benjamn commented May 7, 2020

Try beta.46 (just released), which includes PR #6221?

@benjamn benjamn added this to the Release 3.0 milestone May 7, 2020
@StinsonZhao
Copy link

StinsonZhao commented May 8, 2020

The same problem when using beta.43... T_T

const { data, loading, error, networkStatus } = useQuery(MY_CERTAIN_QUERY)
// loading is aways true
// networkStatus always equals to 1

Then, I tried beta.46 as @benjamn said above. Emm... New Problem:

  • networkStatus can change from 1 to 7, that means the loading can change to false
  • But, the data is undefined(error is also undefined)

I'm very sure that my QUERY is correct. The Network of Chrome DevTools shows the request was returned with data correctly.

By the way, not all of my queries can meet this problem, just some of them, but I cannot know why and how to fix it.


The workaround, I set fetchPolicy = 'network-only' and the data is correct finally.

@samrith-s
Copy link
Author

@benjamn The loading works. But there is a new issue with useLazyQuery and error. I will create a new issue for it.

@hwillson
Copy link
Member

It looks like the original issue was fixed by @apollo/client@3.0.0-beta.46, so closing this off. Thanks!

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

No branches or pull requests

4 participants