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

Function Projects

examples/preact/suspense/src/components/Projects.tsx:6–35  ·  view source on GitHub ↗
({
  setActiveProject,
}: {
  setActiveProject: (activeProject: string | null) => void
})

Source from the content-addressed store, hash-verified

4import Spinner from './Spinner'
5
6export default function Projects({
7 setActiveProject,
8}: {
9 setActiveProject: (activeProject: string | null) => void
10}) {
11 const queryClient = useQueryClient()
12 const { data, isFetching } = useSuspenseQuery(projectsQueries.list())
13
14 return (
15 <div>
16 <h1>TanStack Repositories {isFetching ? <Spinner /> : null}</h1>
17 {data.map((project) => (
18 <p key={project.full_name}>
19 <Button
20 onClick={() => {
21 // Prefetch the project query
22 queryClient
23 .query(projectsQueries.detail(project.full_name))
24 .catch(noop)
25 setActiveProject(project.full_name)
26 }}
27 >
28 Load
29 </Button>{' '}
30 {project.name}
31 </p>
32 ))}
33 </div>
34 )
35}

Callers

nothing calls this directly

Calls 3

useQueryClientFunction · 0.90
useSuspenseQueryFunction · 0.90
queryMethod · 0.45

Tested by

no test coverage detected