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

Function Post

examples/react/basic/src/index.tsx:92–123  ·  view source on GitHub ↗
({
  postId,
  setPostId,
}: {
  postId: number
  setPostId: React.Dispatch<React.SetStateAction<number>>
})

Source from the content-addressed store, hash-verified

90 })
91}
92
93function Post({
94 postId,
95 setPostId,
96}: {
97 postId: number
98 setPostId: React.Dispatch<React.SetStateAction<number>>
99}) {
100 const { status, data, error, isFetching } = usePost(postId)
101
102 return (
103 <div>
104 <div>
105 <a onClick={() => setPostId(-1)} href="#">
106 Back
107 </a>
108 </div>
109 {!postId || status === 'pending' ? (
110 'Loading...'
111 ) : status === 'error' ? (
112 <span>Error: {error.message}</span>
113 ) : (
114 <>
115 <h1>{data.title}</h1>
116 <div>
117 <p>{data.body}</p>
118 </div>
119 <div>{isFetching ? 'Background Updating...' : ' '}</div>
120 </>
121 )}
122 </div>
123 )
124}
125function usePosts() {
126 return useQuery({

Callers

nothing calls this directly

Calls 1

usePostFunction · 0.70

Tested by

no test coverage detected