import React from "react"; import "../../common/styles/gallery.css"; import { LinkContainer } from "react-router-bootstrap"; import { API } from "aws-amplify"; import CategoryGalleryBook from "./CategoryGalleryBook"; import { Book } from "../bestSellers/BestSellerProductRow"; interface CategoryGalleryTeaserProps {} interface CategoryGalleryTeaserState { isLoading: boolean; books: Book[]; } export class CategoryGalleryTeaser extends React.Component { constructor(props: CategoryGalleryTeaserProps) { 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=Cookbooks", null); } render() { return ( this.state.isLoading ?
:

Cookbooks Browse cookbooks

{this.state.books.slice(0,4).map(book => )}
); } } export default CategoryGalleryTeaser;