mirror of
https://github.com/TanStack/query.git
synced 2026-11-16 22:50:20 +00:00
* chore(*): adopt '@tanstack/oxlint-config' and '@tanstack/oxfmt-config', and fix the newly reported lint errors * chore(pnpm-lock.yaml): run 'pnpm dedupe' * chore(scripts): move 'oxlint/plugin.ts' to 'oxlint-plugin.ts' to match the flat layout of 'scripts' * chore(pnpm-workspace.yaml): update '@typescript-eslint/parser' and '@typescript-eslint/rule-tester' to '^8.72.1' to match the deduped '@typescript-eslint/utils' |
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