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
import React from 'react'; | |
import Constantes from "./Constantes"; | |
import { ToastContainer } from 'react-toastify'; | |
import 'react-toastify/dist/ReactToastify.css'; | |
import FilaDeTablaDeVideojuego from './FilaDeTablaDeVideojuego'; | |
class VerVideojuegos extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
videojuegos: [], | |
}; | |
} | |
async componentDidMount() { | |
const respuesta = await fetch(`${Constantes.RUTA_API}`); | |
const videojuegos = await respuesta.json(); | |
this.setState({ | |
videojuegos: videojuegos, | |
}); | |
} | |
render() { | |
return ( | |
<div> | |
<div className="column"> | |
<h1 className="is-size-3">Ver videojuegos</h1> | |
<ToastContainer></ToastContainer> | |
</div> | |
<div className="table-container"> | |
<table className="table is-fullwidth is-bordered"> | |
<thead> | |
<tr> | |
<th>Nombre</th> | |
<th>Precio</th> | |
<th>Calificación</th> | |
<th>Editar</th> | |
<th>Eliminar</th> | |
</tr> | |
</thead> | |
<tbody> | |
{this.state.videojuegos.map(videojuego => { | |
return <FilaDeTablaDeVideojuego key={videojuego._id} videojuego={videojuego}></FilaDeTablaDeVideojuego>; | |
})} | |
</tbody> | |
</table> | |
</div> | |
</div> | |
); | |
} | |
} | |
export default VerVideojuegos; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment