Adding book info cards to homepage
This commit is contained in:
parent
06e7600809
commit
1f8f1793a9
|
@ -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>
|
||||
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue