api fetch type fixed

This commit is contained in:
VividTruthKeeper 2022-08-20 00:16:12 +05:00
parent 222390c412
commit 313a30d0dd
2 changed files with 14 additions and 3 deletions

View File

@ -136,7 +136,7 @@ export const getAbout = (setState: React.Dispatch<About>) => {
.catch();
};
export const getTeam = (setState: any) => {
export const getTeam = (setState: React.Dispatch<Player[]>) => {
axios
.get(players)
.then((res) => {

View File

@ -18,8 +18,19 @@ import useMediaQuery from "../hooks/useMediaQuery";
// Links
import { hosting } from "../links";
// Types
import { Player } from "../types/players";
const Rating = () => {
const [players, setPlayers]: [any, React.Dispatch<any>] = useState();
const [players, setPlayers]: [Player[], React.Dispatch<Player[]>] = useState([
{
id: -1,
name: "",
average: -1,
national: -1,
img: "",
},
]);
useEffect(() => {
window.scrollTo(0, 0);
}, []);
@ -42,7 +53,7 @@ const Rating = () => {
<div
className={players ? "rating-banner" : "rating-banner disabled"}
>
{players
{players[0].id !== -1
? players.map((player: any) => {
if (player.national === 0) {
return (