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