-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9aafc70
commit 1a11dda
Showing
5 changed files
with
25 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import Pokemon from "../models/Pokemon"; | ||
import APIClient from "../services/apiClient"; | ||
import ms from "ms"; | ||
|
||
const client = new APIClient<Pokemon>('/pokemon'); | ||
|
||
const usePokemon = (id: number) => useQuery<Pokemon, Error>({ | ||
queryKey: ['pokemon', id], | ||
queryFn: () => client.get(id), | ||
staleTime: ms('24h') | ||
}) | ||
|
||
export default usePokemon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import Pokemon from "../models/Pokemon"; | ||
import APIClient from "../services/apiClient"; | ||
import ms from "ms"; | ||
|
||
const client = new APIClient<Pokemon>('/api/pokemon'); | ||
|
||
const usePokemonByUrl = (url: string) => useQuery<Pokemon, Error>({ | ||
queryKey: ['pokemonUrl', url], | ||
queryFn: () => client.find(url), | ||
staleTime: ms('24h') | ||
}) | ||
|
||
export default usePokemonByUrl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import APIClient from "../services/apiClient"; | ||
import PokemonResult from "../models/PokemonResult"; | ||
import ms from "ms"; | ||
|
||
const client = new APIClient<PokemonResult>('/pokemon') | ||
|
||
const usePokemons = () => useQuery({ | ||
queryKey: ['pokemons'], | ||
queryFn: client.getAll | ||
queryFn: client.getAll, | ||
staleTime: ms('24h') | ||
}) | ||
|
||
export default usePokemons |