| 13 | const queryClient = new QueryClient() |
| 14 | |
| 15 | function App() { |
| 16 | const [postId, setPostId] = createSignal<string | null>(null) |
| 17 | |
| 18 | return ( |
| 19 | <QueryClientProvider client={queryClient}> |
| 20 | <SolidQueryDevtools /> |
| 21 | <p> |
| 22 | As you visit the posts below, you will notice them in a loading state |
| 23 | the first time you load them. However, after you return to this list and |
| 24 | click on any posts you have already visited again, you will see them |
| 25 | load instantly and background refresh right before your eyes!{' '} |
| 26 | <strong> |
| 27 | (You may need to throttle your network speed to simulate longer |
| 28 | loading sequences) |
| 29 | </strong> |
| 30 | </p> |
| 31 | <Show when={postId()} fallback={<Posts setPostId={setPostId} />}> |
| 32 | {(id) => <Post postId={id()} setPostId={setPostId} />} |
| 33 | </Show> |
| 34 | </QueryClientProvider> |
| 35 | ) |
| 36 | } |
| 37 | |
| 38 | function Posts(props: { setPostId: Setter<string | null> }) { |
| 39 | const state = useQuery(() => postsQueries.list()) |