This repository has been archived on 2026-10-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
level-up-react-client/src/components/game/GameList.js
T
2022-02-15 15:03:45 -06:00

40 lines
1.1 KiB
JavaScript

import React, { useEffect, useState } from "react"
import { getGames } from "./GameManager.js"
import { UpdateEvent } from "./UpdateEvent.js"
export const GameList = (props) => {
const [ games, setGames ] = useState([])
useEffect(() => {
getGames().then(data => setGames(data))
},
[]
)
return (
<>
<article className="games">
<button className="btn btn-2 btn-sep icon-create"
onClick={
() => {
history.push(
{ pathname: "/games/new" }
)
}
}
>Register New Game</button>
{
games.map(game => {
return <section key={`game--${game.id}`} className="game">
<div className="game__title">{game.title} by {game.maker}</div>
<div className="game__players">{game.number_of_players} players needed</div>
<div className="game__skillLevel">Skill level is {game.skill_level}</div>
</section>
})
}
</article>
</>
)
}