({
postId,
setPostId,
}: {
postId: number
setPostId: (postId: number) => void
})
| 65 | } |
| 66 | |
| 67 | function Post({ |
| 68 | postId, |
| 69 | setPostId, |
| 70 | }: { |
| 71 | postId: number |
| 72 | setPostId: (postId: number) => void |
| 73 | }) { |
| 74 | const { status, data, error, isFetching } = useQuery( |
| 75 | postsQueries.detail(postId), |
| 76 | ) |
| 77 | |
| 78 | return ( |
| 79 | <div> |
| 80 | <div> |
| 81 | <a onClick={() => setPostId(-1)} href="#"> |
| 82 | Back |
| 83 | </a> |
| 84 | </div> |
| 85 | {status === 'pending' ? ( |
| 86 | 'Loading...' |
| 87 | ) : status === 'error' ? ( |
| 88 | <span>Error: {error.message}</span> |
| 89 | ) : ( |
| 90 | <> |
| 91 | <h1>{data.title}</h1> |
| 92 | <div> |
| 93 | <p>{data.body}</p> |
| 94 | </div> |
| 95 | <div>{isFetching ? 'Background Updating...' : ' '}</div> |
| 96 | </> |
| 97 | )} |
| 98 | </div> |
| 99 | ) |
| 100 | } |
| 101 | |
| 102 | function App() { |
| 103 | const [postId, setPostId] = useState(-1) |
nothing calls this directly
no test coverage detected