Skip to content

Commit

Permalink
added action
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Jan 1, 2016
1 parent d0a4410 commit b0dee24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion book_list/src/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export function selectBook(book) {
console.log('A book has been selected:', book.title);
// selectBook is an ActionCreator, it needs to return an action,
// an object with a type property.
return {
type: 'BOOK_SELECTED',
payload: book
};
}
7 changes: 6 additions & 1 deletion book_list/src/containers/book-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ class BookList extends Component {
renderList() {
return this.props.books.map((book) => {
return (
<li key={book.title} className="list-group-item">{book.title}</li>
<li
key={book.title}
onClick={() => this.props.selectBook(book)}
className="list-group-item">
{book.title}
</li>
);
});
}
Expand Down

0 comments on commit b0dee24

Please sign in to comment.