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