Adding book info cards to homepage

This commit is contained in:
Ray 2023-10-17 10:00:13 +00:00 committed by GitHub
parent 06e7600809
commit 1f8f1793a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 40 additions and 1 deletions

View File

@ -1,3 +1,42 @@
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import Container from "react-bootstrap/Container";
import Card from "react-bootstrap/Card";
import { useState, useEffect } from "react"
export function Home ( props ) {
return ( <h1>{props.greeting} </h1>)
const [ books, setBooks ] = useState([])
useEffect( () => {
setBooks( props.items )
console.log( props.items )
},[props.items])
// collection
const Items = books.map( (item, key) => {
return (
<Col key={key} md="4">
<Card>
<Card.Body>
<Card.Title>{item.book_title}</Card.Title>
<Card.Text>
By {item.author}
</Card.Text>
</Card.Body>
</Card>
</Col>
)
})
return (
<Container>
<Row>
{Items}
</Row>
</Container>
)
}