Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 21, 2020 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/d2e5cdd066a06bf6238a7800133a4048 to your computer and use it in GitHub Desktop.
Save parzibyte/d2e5cdd066a06bf6238a7800133a4048 to your computer and use it in GitHub Desktop.
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