1
1
/* eslint-disable jsx-a11y/anchor-is-valid */
2
- import React from 'react' ;
3
- import ReactDOM from 'react-dom/client' ;
2
+ import React from 'react'
3
+ import ReactDOM from 'react-dom/client'
4
4
import {
5
5
useQuery ,
6
6
useQueryClient ,
7
7
QueryClient ,
8
8
QueryClientProvider ,
9
- } from '@tanstack/react-query' ;
10
- import { ReactQueryDevtools } from '@tanstack/react-query-devtools' ;
11
- import { request , gql } from 'graphql-request' ;
9
+ } from '@tanstack/react-query'
10
+ import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
11
+ import { request , gql } from 'graphql-request'
12
12
13
- const endpoint = 'https://graphqlzero.almansi.me/api' ;
13
+ const endpoint = 'https://graphqlzero.almansi.me/api'
14
14
15
- const queryClient = new QueryClient ( ) ;
15
+ const queryClient = new QueryClient ( )
16
16
17
17
function App ( ) {
18
- const [ postId , setPostId ] = React . useState ( - 1 ) ;
18
+ const [ postId , setPostId ] = React . useState ( - 1 )
19
19
20
20
return (
21
21
< QueryClientProvider client = { queryClient } >
@@ -36,7 +36,7 @@ function App() {
36
36
) }
37
37
< ReactQueryDevtools initialIsOpen />
38
38
</ QueryClientProvider >
39
- ) ;
39
+ )
40
40
}
41
41
42
42
function usePosts ( ) {
@@ -57,15 +57,15 @@ function usePosts() {
57
57
}
58
58
}
59
59
`
60
- ) ;
61
- return data ;
60
+ )
61
+ return data
62
62
} ,
63
- } ) ;
63
+ } )
64
64
}
65
65
66
66
function Posts ( { setPostId } ) {
67
- const queryClient = useQueryClient ( ) ;
68
- const { status, data, error, isFetching } = usePosts ( ) ;
67
+ const queryClient = useQueryClient ( )
68
+ const { status, data, error, isFetching } = usePosts ( )
69
69
70
70
return (
71
71
< div >
@@ -104,7 +104,7 @@ function Posts({ setPostId }) {
104
104
) }
105
105
</ div >
106
106
</ div >
107
- ) ;
107
+ )
108
108
}
109
109
110
110
function usePost ( postId ) {
@@ -122,15 +122,15 @@ function usePost(postId) {
122
122
}
123
123
}
124
124
`
125
- ) ;
126
- return post ;
125
+ )
126
+ return post
127
127
} ,
128
128
enabled : postId > - 1 ,
129
- } ) ;
129
+ } )
130
130
}
131
131
132
132
function Post ( { postId, setPostId } ) {
133
- const { status, data, error, isFetching } = usePost ( postId ) ;
133
+ const { status, data, error, isFetching } = usePost ( postId )
134
134
135
135
return (
136
136
< div >
@@ -153,8 +153,8 @@ function Post({ postId, setPostId }) {
153
153
</ >
154
154
) }
155
155
</ div >
156
- ) ;
156
+ )
157
157
}
158
158
159
- const rootElement = document . getElementById ( 'root' ) ;
160
- ReactDOM . createRoot ( rootElement ) . render ( < App /> ) ;
159
+ const rootElement = document . getElementById ( 'root' )
160
+ ReactDOM . createRoot ( rootElement ) . render ( < App /> )
0 commit comments