Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

cached-diff.tsrx

26 lines566 Bytes

1import {
2 QueryClient,
3 QueryClientProvider,
4 useQuery,
5} from '@tanstack/octane-query';
6​
7const client = new QueryClient();
8​
9export function Cached() @{
10 const q = useQuery({
11 queryKey: ['c'],
12 queryFn: () => Promise.resolve('fetched'),
13 initialData: 'seed',
14 staleTime: Infinity,
15 });
16 <div id="d">{'data=' + q.data + ' status=' + q.status + ' pending=' + q.isPending + ' fetching=' +
17 q.isFetching +
18 ' success=' +
19 q.isSuccess as string}</div>
21​
22export function CachedApp() @{
23 <QueryClientProvider client={client}>
24 <Cached />
25 </QueryClientProvider>