import React from "react"; import "../../common/styles/gallery.css"; import { API } from "aws-amplify"; import CategoryGalleryBook from "./CategoryGalleryBook"; import { Book } from "../bestSellers/BestSellerProductRow"; interface CategoryGalleryProps { match: any; } interface CategoryGalleryState { isLoading: boolean; books: Book[]; } export class CategoryGallery extends React.Component { constructor(props: CategoryGalleryProps) { super(props); this.state = { isLoading: true, books: [] }; } async componentDidMount() { try { const books = await this.listBooks(); this.setState({ books }); } catch (e) { alert(e); } this.setState({ isLoading: false }); } listBooks() { return API.get("books", `/books?category=${this.props.match.params.id}`, null); } render() { return ( this.state.isLoading ?
:

{this.props.match.params.id}

{this.state.books.map(book => )}
); } } export default CategoryGallery;