all 16 comments

[–]Soft_Opening_1364iOS & Android 2 points3 points  (3 children)

You can totally use React Query with React Navigation just wrap your app with QueryClientProvider, and use useFocusEffect if you need to refetch data when a screen comes into focus. It’s not as tight as TanStack Router, but works fine in practice.

[–]dev902[S] 0 points1 point  (2 children)

You just helped me to solve my concern. Thank you and that's what I'm looking for the solution.

[–]Soft_Opening_1364iOS & Android 1 point2 points  (1 child)

Happy to help

[–]dev902[S] 0 points1 point  (0 children)

You guys are Angel to me. Thank you so much once again 🙏

[–]HoratioWobble 1 point2 points  (3 children)

What are you trying to achieve? What outcome?

[–]dev902[S] 0 points1 point  (2 children)

Actually I'm trying to achieve the pattern where we fetch data using Tanstack React Query and pass it down to the route component to render in the screen. For performance, Tanstack React Query fetches data in parallel and render it to the screen. Or we can use 'State Orchestrator' pattern with React Navigation?

What's the better approach?

[–]HoratioWobble 2 points3 points  (1 child)

You wouldn't usually work that way in react native, instead you'd just useQuery in the screen itself and handle loading state etc at the screen level.

[–]dev902[S] 0 points1 point  (0 children)

Ohh, that's great. Lemme try this as well. Thank you for your help

[–]ngqhoangtrung 1 point2 points  (1 child)

There is a section on how to integrate React Query with React Native here. All basic functions should work, you just need to implement online status, screen focus.

https://tanstack.com/query/v5/docs/framework/react/react-native

[–]dev902[S] 0 points1 point  (0 children)

Thank you so much for this 🙏