-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBookShelf.js
38 lines (34 loc) · 1.23 KB
/
BookShelf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import Books from './Books'
class BookShelf extends Component {
static propTypes = {
name: PropTypes.string.isRequired,
books: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired,
handleUpdate: PropTypes.func.isRequired
}
render() {
const {name, books, handleUpdate} = this.props
return (
<div>
{books && (
<div className="bookshelf">
<h2 className="bookshelf-title">{name}</h2>
<div className="bookshelf-books">
<ol className="books-grid">
{books.length > 0 && books.map((book, index) => (
<Books
key={index}
book={book}
changeBookShelf={handleUpdate}
/>
))}
</ol>
</div>
</div>
)}
</div>
)
}
}
export default BookShelf