Function
Post
({
postId,
setPostId,
}: {
postId: number
setPostId: React.Dispatch<React.SetStateAction<number>>
})
Source from the content-addressed store, hash-verified
| 90 | }) |
| 91 | } |
| 92 | |
| 93 | function 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 | } |
| 125 | function usePosts() { |
| 126 | return useQuery({ |
Callers
nothing calls this directly
Tested by
no test coverage detected