0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-16 22:50:20 +00:00
query/examples/react/react-native
Wonsuk Choi 70441f460d
docs(examples): rewrite the READMEs, add the framework or router to example titles, and rename examples to '<feature>-<framework>' (#12583)
* docs(examples): describe each example in its README with a summary, the framework it is built with, how it works and the npm commands

* docs(examples): add the framework or router to the README heading and page title of examples that have variants

* docs(examples/react): rename the Next.js examples to '<feature>-nextjs-<pages|app>-router'

* docs(examples/react): update package names, docs links and labels, and the lockfile for the renamed Next.js examples

* docs(examples): rename 'svelte/sveltekit', 'solid/solid-start-streaming' and 'angular/router' to '<feature>-<framework>'

* docs(examples): correct README details on staleness, hydration, 'hasMore', streaming and dependent queries, and prefetch on 'focusin' in 'vue/prefetching-nuxt4'
History 2026-11-12 16:58:15 +09:00
..
assets v4 release (#3842) 2022-07-18 12:08:12 -06:00
src refactor(examples/react/{batching,chat,react-native}): move the data layer into 'services/{domain}' with a query factory (#12353) 2026-10-26 00:11:05 +09:00
.gitignore chore(examples/react/react-native): upgrade to Expo SDK 58 and resolve 'expo-doctor' issues (#12417) 2026-10-27 14:55:18 +09:00
app.json docs(examples): unify page titles to 'TanStack <Framework> Query <Name> Example' and remove scaffold leftovers (#12580) 2026-11-12 14:54:59 +09:00
App.tsx feat(examples/react/react-native): render 'ReactQueryDevtools' on web through a platform-specific 'Devtools' component (#12093) 2026-10-18 23:01:44 +09:00
babel.config.js feat: beta release (#5771) 2023-07-24 11:59:07 +02:00
eslint.config.mjs chore(examples/react/react-native): add a flat config and run 'test:eslint' (#12039) 2026-10-17 01:08:08 +09:00
package.json ci: Version Packages (#12543) 2026-11-07 00:00:45 +01:00
README.md docs(examples): rewrite the READMEs, add the framework or router to example titles, and rename examples to '<feature>-<framework>' (#12583) 2026-11-12 16:58:15 +09:00
tsconfig.json feat: beta release (#5771) 2023-07-24 11:59:07 +02:00

TanStack React Query React Native Example

A movies app for React Native (Expo). Queries refetch when the app comes to the foreground and when the network reconnects, through focusManager and onlineManager, and support pull to refresh.

Built with Expo.

How it works

  • src/services/movies/queries.ts defines moviesQueries.list() and moviesQueries.detail(title) with queryOptions. src/services/movies/api.ts reads src/data/movies.json after a random delay of up to about 2 seconds.
  • App.tsx calls focusManager.setFocused from the AppState listener in src/hooks/useAppState.ts, and src/hooks/useOnlineManager.ts feeds NetInfo's connection state into onlineManager.setEventListener. Both are skipped on web, where the browser events already cover this.
  • src/screens/MoviesListScreen.tsx reads useQuery(moviesQueries.list()), supports pull to refresh through src/hooks/useRefreshByUser.ts, and uses src/hooks/useRefreshOnFocus.ts to call queryClient.refetchQueries({ stale: true, type: 'active' }) when the screen regains navigation focus.
  • src/screens/MovieDetailsScreen.tsx reads the detail query with a placeholderData function that takes the matching movie from the cached list via queryClient.getQueryData(moviesQueries.list().queryKey), so the title and year show while the full details load.

To run this example:

  • npm install
  • npm start