-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.jsx
39 lines (33 loc) · 1.21 KB
/
index.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, { useState, useEffect } from "react";
import rawgApi from "../../../services/rawgApi";
import LinksSidebar from "../../../components/LinksSidebar";
import RawgTopRatedGames from "../../../components/RawgTopRatedGames";
const TopRatedGames = () => {
// State for top games list from RAWG Api
const [allGamesList, setAllGamesList] = useState([]);
useEffect(() => {
// Fetch top games list when component mounts
fetchRawgAllGamesList();
}, []);
const fetchRawgAllGamesList = async () => {
try {
const response = await rawgApi.getGamesList;
setAllGamesList(response.data.results);
} catch (error) {
console.error("Error fetching top rated games:", error);
}
};
return (
<div className="grid grid-cols-4">
<div className="bg-secondary text-text h-full hidden md:block">
<LinksSidebar />
</div>
<div className="col-span-4 md:col-span-3 bg-primary text-text">
{allGamesList?.length > 0 && (
<RawgTopRatedGames gamesList={allGamesList} />
)}
</div>
</div>
)
}
export default TopRatedGames;