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

Function App

examples/preact/basic/src/index.tsx:102–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected