File tree Expand file tree Collapse file tree 3 files changed +1
-59
lines changed Expand file tree Collapse file tree 3 files changed +1
-59
lines changed Original file line number Diff line number Diff line change @@ -10,21 +10,13 @@ import {
10
10
} from '@tanstack/react-query'
11
11
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
12
12
13
- const queryClient = new QueryClient ( {
14
- defaultOptions : {
15
- queries : {
16
- staleTime : 60 * 1000 ,
17
- } ,
18
- } ,
19
- } )
13
+ const queryClient = new QueryClient ( )
20
14
21
15
function App ( ) {
22
16
const [ postId , setPostId ] = React . useState ( - 1 )
23
17
24
18
return (
25
19
< QueryClientProvider client = { queryClient } >
26
- < Test />
27
-
28
20
< p >
29
21
As you visit the posts below, you will notice them in a loading state
30
22
the first time you load them. However, after you return to this list and
@@ -143,28 +135,5 @@ function Post({ postId, setPostId }) {
143
135
)
144
136
}
145
137
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
-
169
138
const rootElement = document . getElementById ( 'root' )
170
139
ReactDOM . createRoot ( rootElement ) . render ( < App /> )
Original file line number Diff line number Diff line change 8
8
defaultOptions: {
9
9
queries: {
10
10
enabled: browser ,
11
- staleTime: 60 * 1000 ,
12
11
},
13
12
},
14
13
})
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments