Skip to content

Commit

Permalink
Merge pull request #13 from iks3000/component-container
Browse files Browse the repository at this point in the history
Component container
  • Loading branch information
iks3000 authored May 28, 2020
2 parents 6967a82 + b1ecacb commit 59f61ef
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/components/book-list/book-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,22 @@ import { fetchBooks } from '../../actions';
import { compose } from '../../utils';
import './book-list.css';

class BookList extends Component {
const BookList = ({ books }) => {
return (
<ul className="book-list d-flex flex-wrap justify-content-start p-0">
{
books.map((bookItem) => {
return (
<li key={bookItem.id}>
<BookListItem book={bookItem} />
</li>
)
})
}
</ul>
)
};
class BookListContainer extends Component {

componentDidMount() {
this.props.fetchBooks();
Expand All @@ -23,19 +38,7 @@ class BookList extends Component {
if (error) {
return <ErrorIndicator />
}
return (
<ul className="book-list d-flex flex-wrap justify-content-start p-0">
{
books.map((bookItem) => {
return (
<li key={bookItem.id}>
<BookListItem book={bookItem} />
</li>
)
})
}
</ul>
)
return <BookList books={books} />
}
};

Expand All @@ -53,4 +56,4 @@ const mapDispatchToProps = (dispatch, ownProps) => {
export default compose(
withBookstoreService(),
connect(mapStateToProps, mapDispatchToProps)
)(BookList);
)(BookListContainer);

0 comments on commit 59f61ef

Please sign in to comment.