question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useQuery/useLazyQuery stuck on "loading" state in expo/react-native devices

See original GitHub issue

In latest versions of Expo React Native (also newest versions of Apollo Client for React) useQuery no longer works. Any query executed with Apollo client works well in the web, but on mobile devices (both real device and emulator) is stuck on “loading” state. No error is returned.

Intended outcome:

Execute a query with apollo client on new expo application. Receive data.

Actual outcome:

Query is executed but stuck on “loading”. Both useQuery and useLazyQuery. The properties of object returned by useQuery are as follows: data - undefined, error, undefined, loading - true.

How to reproduce the issue:

  1. Create an Expo project (https://reactnative.dev/docs/environment-setup)
  2. Add Apollo Client and configure it (https://www.apollographql.com/docs/react/integrations/react-native/)
  3. Start the project and run in on Android device

The example project recommended on Apollo website, after upgrading the libs to newest versions, is not working to (no data is shown after application start - always loading). https://github.com/GraphQLGuide/guide-react-native

Versions

System: OS: Windows 10 10.0.19044 Binaries: Node: 16.14.2 - E:\Tools\Node\node.EXE npm: 8.5.3 - E:\Tools\Node\npm.CMD Browsers: Chrome: 100.0.4896.127 Edge: Spartan (44.19041.1266.0), Chromium (101.0.1210.32) npmPackages: @apollo/client: ^3.2.1 => 3.6.2

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:11
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
dominik-myszkowskicommented, May 10, 2022

Looks like new alhpa version solves the case. (3.7.0-beta.3)

npm i @apollo/client@beta

https://github.com/apollographql/apollo-client/issues/9668#issuecomment-1121656608

2reactions
darrylyoungcommented, May 9, 2022

It also works for me if I downgrade to version 3.5.10. Has anyone else tried the upcoming version 3.6.3? I just tried it but it still wasn’t working for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'loading' remains true when loading data with 'useQuery' using ...
I'm trying to fetch data using Apollo Client useQuery in React Native, but loading hangs ...
Read more >
Loading stuck on true when using useLazyQuery in React - Help
Hey fellas, i'm using useLazyQuery to login to the server. it was working great until today. It suddenly stopped working.
Read more >
react use lazy query Code Example
const { data: cachedData } = useQuery(MyQuery, { fetchPolicy: 'cache-only', variables }); const [executeMyQuery, { data: queryData, loading, ...
Read more >
Learn from 425 web development courses on egghead
The videos are recorded on a Mac with an iPhone 13 Simulator using plain React Native, but you can do this course using...
Read more >
How to Integrate GraphQL and Apollo Client in a React Native ...
The useQuery hook gives one property called loading that can be used to indicate on the device's screen when the query is in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found