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

Project.tsx

34 lines937 Bytes

1import { Show } from 'solid-js'
2import { useQuery } from '@tanstack/solid-query'
3import { projectsQueries } from '../services/projects/queries'
4import Button from './Button'
5import Spinner from './Spinner'
6​
7export default function Project(props: {
8 activeProject: string
9 setActiveProject: (project: string | null) => void
10}) {
11 const projectQuery = useQuery(() => ({
12 ...projectsQueries.detail(props.activeProject),
13 throwOnError: true,
14 }))
15​
16 return (
17 <div>
18 <Button onClick={() => props.setActiveProject(null)}>Back</Button>
19 <h1>
20 {props.activeProject}{' '}
21 <Show when={projectQuery.isFetching}>
22 <Spinner />
23 </Show>
24 </h1>
25 <div>
26 <p>forks: {projectQuery.data?.forks_count}</p>
27 <p>stars: {projectQuery.data?.stargazers_count}</p>
28 <p>watchers: {projectQuery.data?.subscribers_count}</p>
29 </div>
30 <br />
31 <br />
32 </div>
33 )