()
| 24 | } |
| 25 | |
| 26 | function createPosts() { |
| 27 | return useQuery(() => ({ |
| 28 | queryKey: ['posts'], |
| 29 | queryFn: async (): Promise<Array<Post>> => { |
| 30 | const response = await fetch('https://jsonplaceholder.typicode.com/posts') |
| 31 | return await response.json() |
| 32 | }, |
| 33 | })) |
| 34 | } |
| 35 | |
| 36 | function Posts(props: { setPostId: Setter<number> }) { |
| 37 | const state = createPosts() |