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

Callers

nothing calls this directly

Calls 1

usePostFunction · 0.70

Tested by

no test coverage detected