@@ -10,21 +10,13 @@ import {
1010} from '@tanstack/react-query'
1111import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
1212
13- const queryClient = new QueryClient ( {
14- defaultOptions : {
15- queries : {
16- staleTime : 60 * 1000 ,
17- } ,
18- } ,
19- } )
13+ const queryClient = new QueryClient ( )
2014
2115function App ( ) {
2216 const [ postId , setPostId ] = React . useState ( - 1 )
2317
2418 return (
2519 < QueryClientProvider client = { queryClient } >
26- < Test />
27-
2820 < p >
2921 As you visit the posts below, you will notice them in a loading state
3022 the first time you load them. However, after you return to this list and
@@ -143,28 +135,5 @@ function Post({ postId, setPostId }) {
143135 )
144136}
145137
146- function Test ( ) {
147- const [ id , setId ] = React . useState ( 1 )
148-
149- const query = useQuery ( {
150- queryKey : [ 'myquery' , id ] ,
151- queryFn : async ( ) =>
152- await fetch ( `https://swapi.dev/api/people/${ id } ` ) . then ( ( r ) => r . json ( ) ) ,
153- } )
154-
155- return (
156- < >
157- < input onChange = { ( e ) => setId ( e . target . value ) } value = { id } />
158- { query . isPending ? (
159- < p > Loading...</ p >
160- ) : query . isError ? (
161- < p > Error: { query . error . message } </ p >
162- ) : (
163- < pre > { JSON . stringify ( query . data , null , 2 ) } </ pre >
164- ) }
165- </ >
166- )
167- }
168-
169138const rootElement = document . getElementById ( 'root' )
170139ReactDOM . createRoot ( rootElement ) . render ( < App /> )
0 commit comments