MCPcopy Create free account
hub / github.com/TanStack/query / App

Function App

examples/preact/basic-graphql-request/src/index.tsx:14–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12const queryClient = new QueryClient()
13
14function App() {
15 const [postId, setPostId] = useState<string | null>(null)
16
17 return (
18 <QueryClientProvider client={queryClient}>
19 <p>
20 As you visit the posts below, you will notice them in a loading state
21 the first time you load them. However, after you return to this list and
22 click on any posts you have already visited again, you will see them
23 load instantly and background refresh right before your eyes!{' '}
24 <strong>
25 (You may need to throttle your network speed to simulate longer
26 loading sequences)
27 </strong>
28 </p>
29 {postId !== null ? (
30 <Post postId={postId} setPostId={setPostId} />
31 ) : (
32 <Posts setPostId={setPostId} />
33 )}
34 <PreactQueryDevtools initialIsOpen />
35 </QueryClientProvider>
36 )
37}
38
39function Posts({ setPostId }: { setPostId: (postId: string | null) => void }) {
40 const queryClient = useQueryClient()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected