import { Component } from "react";
import { Element } from "./Element";

export class Liste extends Component {
    constructor(props) {
        super(props);
        this.state = {
            games: []
        }
    }
    componentDidMount() {
        const url = "https://localhost:1235/leadervoard";
        fetch(url)
            .then(response => response.json())
            .then(json => this.setState({ games: json }))
    }
    render() {
        const { games } = this.state;

        const testx = [];

        for (let i = 0; i < 10; i++) {
            testx.push(<Element index={i} />);
        }
        return (
            <div class="list-group">
                {games.map((game, index) =>
                    <Element index={index} game={game} />
                )}
                {testx}
            </div>
        )
    }
}