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
|
|
|---|---|---|
| .. | ||
| public | ||
| src | ||
| .gitignore | ||
| eslint.config.js | ||
| index.html | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| vite.config.ts | ||
TanStack React Query Chat Example
A chat UI that streams the answer into the query cache with streamedQuery.
How it works
src/services/messages/queries.tsdefinesmessagesQueries.detail(id, question)withqueryOptions, usingexperimental_streamedQuery(imported asstreamedQuery) as thequeryFnandstaleTime: Infinity.src/services/messages/api.tsreturns an async iterable that yields a canned answer word by word with random delays and stops when the query'ssignalis aborted.src/index.tsxrenders aChatMessageper question, which callsuseQuery(messagesQueries.detail(id, question)).datais the array of chunks received so far, joined into the answer, andisFetchingstaystrueuntil the stream ends.
To run this example:
npm installnpm run dev