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

Function App

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

Source from the content-addressed store, hash-verified

104}
105
106function App() {
107 const [postId, setPostId] = React.useState(-1)
108
109 return (
110 <PersistQueryClientProvider
111 client={queryClient}
112 persistOptions={{ persister }}
113 >
114 <p>
115 As you visit the posts below, you will notice them in a loading state
116 the first time you load them. However, after you return to this list and
117 click on any posts you have already visited again, you will see them
118 load instantly and background refresh right before your eyes!{' '}
119 <strong>
120 (You may need to throttle your network speed to simulate longer
121 loading sequences)
122 </strong>
123 </p>
124 {postId > -1 ? (
125 <Post postId={postId} setPostId={setPostId} />
126 ) : (
127 <Posts setPostId={setPostId} />
128 )}
129 <ReactQueryDevtools initialIsOpen />
130 </PersistQueryClientProvider>
131 )
132}
133
134const rootElement = document.getElementById('root')
135if (!rootElement) throw new Error('Missing #root element')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected