()
| 20 | } |
| 21 | |
| 22 | function App() { |
| 23 | const [postId, setPostId] = React.useState(-1) |
| 24 | |
| 25 | return ( |
| 26 | <QueryClientProvider client={queryClient}> |
| 27 | <p> |
| 28 | As you visit the posts below, you will notice them in a loading state |
| 29 | the first time you load them. However, after you return to this list and |
| 30 | click on any posts you have already visited again, you will see them |
| 31 | load instantly and background refresh right before your eyes!{' '} |
| 32 | <strong> |
| 33 | (You may need to throttle your network speed to simulate longer |
| 34 | loading sequences) |
| 35 | </strong> |
| 36 | </p> |
| 37 | {postId > -1 ? ( |
| 38 | <Post postId={postId} setPostId={setPostId} /> |
| 39 | ) : ( |
| 40 | <Posts setPostId={setPostId} /> |
| 41 | )} |
| 42 | <ReactQueryDevtools initialIsOpen /> |
| 43 | </QueryClientProvider> |
| 44 | ) |
| 45 | } |
| 46 | |
| 47 | function usePosts() { |
| 48 | return useQuery({ |
nothing calls this directly
no outgoing calls
no test coverage detected