mirror of
https://github.com/TanStack/query.git
synced 2026-11-16 22:50:20 +00:00
* 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
|
|
|---|---|---|
| .. | ||
| assets | ||
| src | ||
| .gitignore | ||
| app.json | ||
| App.tsx | ||
| babel.config.js | ||
| eslint.config.mjs | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
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.tsdefinesmoviesQueries.list()andmoviesQueries.detail(title)withqueryOptions.src/services/movies/api.tsreadssrc/data/movies.jsonafter a random delay of up to about 2 seconds.App.tsxcallsfocusManager.setFocusedfrom theAppStatelistener insrc/hooks/useAppState.ts, andsrc/hooks/useOnlineManager.tsfeeds NetInfo's connection state intoonlineManager.setEventListener. Both are skipped on web, where the browser events already cover this.src/screens/MoviesListScreen.tsxreadsuseQuery(moviesQueries.list()), supports pull to refresh throughsrc/hooks/useRefreshByUser.ts, and usessrc/hooks/useRefreshOnFocus.tsto callqueryClient.refetchQueries({ stale: true, type: 'active' })when the screen regains navigation focus.src/screens/MovieDetailsScreen.tsxreads the detail query with aplaceholderDatafunction that takes the matching movie from the cached list viaqueryClient.getQueryData(moviesQueries.list().queryKey), so the title and year show while the full details load.
To run this example:
npm installnpm start