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

Function Projects

examples/react/suspense/src/components/Projects.tsx:7–36  ·  view source on GitHub ↗
({
  setActiveProject,
}: {
  setActiveProject: React.Dispatch<React.SetStateAction<string | null>>
})

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

useQueryClientFunction · 0.90
useSuspenseQueryFunction · 0.90
queryMethod · 0.45

Tested by

no test coverage detected