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

@tanstack/[email protected] react-native example does not work - queryFn not being called #4154

Closed
tomskopek opened this issue Sep 12, 2022 · 15 comments · Fixed by #4185
Closed

Comments

@tomskopek
Copy link

tomskopek commented Sep 12, 2022

Describe the bug

I'm trying to migrate from react-query v3. I couldn't get react-query v4.3.4 to work in my react-native app, so I eventually tried the demo app.

The react-native example provided in the repo also doesn't work.
Specifically, the queryFn doesn't seem to be getting called. You can verify this by noting that console.log in fetchMovies() never gets called.

I downgraded the example app to use [email protected], a version I have working in my react web project. I also tried 4.2.3, the last version before 4.3 minor version was released.

Now the console.log in fetchMovies() does get called, as expected.
However, note that now data seems to be returning a function, instead of an array, as I'd expect, so the example repo still is not working out of the box.

Thanks!

Your minimal, reproducible example

https://github.com/TanStack/query/tree/main/examples/react/react-native

Steps to reproduce

Run the expo code example provided in the package, with react-query set to v4.3.4

Expected behavior

As a user, I expect to see a movie list, but I do not.

How often does this bug happen?

No response

Screenshots or Videos

No response

Platform

  • OS - iOS 12.5.1
  • iPhone 13 Pro Max simulator 15.2

react-query version

4.3.4

TypeScript version

No response

Additional context

No response

@tomskopek tomskopek changed the title @tanstack/[email protected] react-native example does not work @tanstack/[email protected] react-native example does not work - queryFn not being called Sep 12, 2022
@TkDodo
Copy link
Collaborator

TkDodo commented Sep 12, 2022

yeah two different things here:

  1. the example needs to be updated, but that's a minor thing.
  2. queryFn not being called. I've seen that one before, it has to do with useSyncExternalStore. I think it was this issue:

@TkDodo
Copy link
Collaborator

TkDodo commented Sep 12, 2022

@DamianOsipiuk FYI

@TkDodo
Copy link
Collaborator

TkDodo commented Sep 12, 2022

@Gedoz
Copy link

Gedoz commented Sep 12, 2022

Me too, downgrade to v4.2.3 and works fine!

@TkDodo TkDodo added the esm label Sep 12, 2022
@gagamil
Copy link

gagamil commented Sep 16, 2022

I have updated my expo based project to the latest expo v 46 (react 18) (from v 45) and queryFn is being called.

@Willham12
Copy link

can confirm the issue!

@TkDodo
Copy link
Collaborator

TkDodo commented Sep 18, 2022

@Willham12 @gagamil @Gedoz @tomskopek can you please try with this version?

"@tanstack/react-query": "https://pkg.csb.dev/TanStack/query/commit/fd83a352/@tanstack/react-query",

it's from the preview build of this PR:

not sure if it actually fixes things for this issue but it's worth a try 😅

@Willham12
Copy link

@Willham12 @gagamil @Gedoz @tomskopek can you please try with this version?

"@tanstack/react-query": "https://pkg.csb.dev/TanStack/query/commit/fd83a352/@tanstack/react-query",

it's from the preview build of this PR:

not sure if it actually fixes things for this issue but it's worth a try 😅
Hi, it's not fixed with this version.

@TkDodo
Copy link
Collaborator

TkDodo commented Sep 18, 2022

ok thx

This was referenced Sep 18, 2022
@TkDodo
Copy link
Collaborator

TkDodo commented Sep 18, 2022

okay, now for another attempt. @Willham12 please try:

"@tanstack/react-query": "https://pkg.csb.dev/TanStack/query/commit/0faab602/@tanstack/react-query",

it's from this PR:

@Willham12
Copy link

okay, now for another attempt. @Willham12 please try:

"@tanstack/react-query": "https://pkg.csb.dev/TanStack/query/commit/0faab602/@tanstack/react-query",

it's from this PR:

LGTM

@TkDodo
Copy link
Collaborator

TkDodo commented Sep 19, 2022

if someone wants to update the react-native example and make it work again, please open a dedicated PR

@dducluzeaud
Copy link
Contributor

Hi!

Thanks for the rapid fix, I really love this library!

I would love to update the react native example. I already made the fix, but I can't push. Sorry if I'm a newbie in OSS. 😅

@TkDodo
Copy link
Collaborator

TkDodo commented Sep 19, 2022

Awesome, thank you. You need to fork the library, then push to your fork and create a PR here

@dducluzeaud
Copy link
Contributor

Thank you! PR has been created.

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

Successfully merging a pull request may close this issue.

6 participants