({
postId,
setPostId,
}: {
postId: string
setPostId: (postId: string | null) => void
})
| 83 | } |
| 84 | |
| 85 | function Post({ |
| 86 | postId, |
| 87 | setPostId, |
| 88 | }: { |
| 89 | postId: string |
| 90 | setPostId: (postId: string | null) => void |
| 91 | }) { |
| 92 | const { status, data, error, isFetching } = useQuery( |
| 93 | postsQueries.detail(postId), |
| 94 | ) |
| 95 | |
| 96 | return ( |
| 97 | <div> |
| 98 | <div> |
| 99 | <a onClick={() => setPostId(null)} href="#"> |
| 100 | Back |
| 101 | </a> |
| 102 | </div> |
| 103 | {status === 'pending' ? ( |
| 104 | 'Loading...' |
| 105 | ) : status === 'error' ? ( |
| 106 | <span>Error: {error.message}</span> |
| 107 | ) : ( |
| 108 | <> |
| 109 | <h1>{data.title}</h1> |
| 110 | <div> |
| 111 | <p>{data.body}</p> |
| 112 | </div> |
| 113 | <div>{isFetching ? 'Background Updating...' : ' '}</div> |
| 114 | </> |
| 115 | )} |
| 116 | </div> |
| 117 | ) |
| 118 | } |
| 119 | |
| 120 | const rootElement = document.getElementById('root') |
| 121 | if (!rootElement) throw new Error('Missing #root element') |
nothing calls this directly
no test coverage detected