MCPcopy Create free account
hub / github.com/TanStack/query / App

Function App

examples/react/basic/src/index.tsx:132–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130}
131
132function App() {
133 const [postId, setPostId] = React.useState(-1)
134
135 return (
136 <PersistQueryClientProvider
137 client={queryClient}
138 persistOptions={{ persister }}
139 >
140 <p>
141 As you visit the posts below, you will notice them in a loading state
142 the first time you load them. However, after you return to this list and
143 click on any posts you have already visited again, you will see them
144 load instantly and background refresh right before your eyes!{' '}
145 <strong>
146 (You may need to throttle your network speed to simulate longer
147 loading sequences)
148 </strong>
149 </p>
150 {postId > -1 ? (
151 <Post postId={postId} setPostId={setPostId} />
152 ) : (
153 <Posts setPostId={setPostId} />
154 )}
155 <ReactQueryDevtools initialIsOpen />
156 </PersistQueryClientProvider>
157 )
158}
159
160const rootElement = document.getElementById('root')
161if (!rootElement) throw new Error('Missing #root element')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected