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

Function Post

examples/solid/basic/src/index.tsx:70–97  ·  view source on GitHub ↗
(props: { postId: number; setPostId: Setter<number> })

Source from the content-addressed store, hash-verified

68}
69
70function Post(props: { postId: number; setPostId: Setter<number> }) {
71 const state = useQuery(() => postsQueries.detail(props.postId))
72
73 return (
74 <div>
75 <div>
76 <a onClick={() => props.setPostId(-1)} href="#">
77 Back
78 </a>
79 </div>
80 <Switch>
81 <Match when={state.status === 'pending'}>Loading...</Match>
82 <Match when={state.status === 'error'}>
83 <span>Error: {(state.error as Error).message}</span>
84 </Match>
85 <Match when={state.data !== undefined}>
86 <>
87 <h1>{state.data?.title}</h1>
88 <div>
89 <p>{state.data?.body}</p>
90 </div>
91 <div>{state.isFetching ? 'Background Updating...' : ' '}</div>
92 </>
93 </Match>
94 </Switch>
95 </div>
96 )
97}
98
99const App: Component = () => {
100 const [postId, setPostId] = createSignal(-1)

Callers

nothing calls this directly

Calls 2

useQueryFunction · 0.90
setPostIdMethod · 0.45

Tested by

no test coverage detected