MCPcopy Index your code
hub / github.com/TanStack/query / Post

Function Post

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

Source from the content-addressed store, hash-verified

96}
97
98function Post(props: { postId: number; setPostId: Setter<number> }) {
99 const state = createPost(props.postId)
100
101 return (
102 <div>
103 <div>
104 <a onClick={() => props.setPostId(-1)} href="#">
105 Back
106 </a>
107 </div>
108 <Switch>
109 <Match when={!props.postId || state.status === 'pending'}>
110 Loading...
111 </Match>
112 <Match when={state.status === 'error'}>
113 <span>Error: {(state.error as Error).message}</span>
114 </Match>
115 <Match when={state.data !== undefined}>
116 <>
117 <h1>{state.data?.title}</h1>
118 <div>
119 <p>{state.data?.body}</p>
120 </div>
121 <div>{state.isFetching ? 'Background Updating...' : ' '}</div>
122 </>
123 </Match>
124 </Switch>
125 </div>
126 )
127}
128
129const App: Component = () => {
130 const [postId, setPostId] = createSignal(-1)

Callers

nothing calls this directly

Calls 1

createPostFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…