From b0dee244fbcb6d3fa8e6d316958417c59a3775c6 Mon Sep 17 00:00:00 2001 From: stephen grider Date: Thu, 31 Dec 2015 18:04:22 -0800 Subject: [PATCH] added action --- book_list/src/actions/index.js | 7 ++++++- book_list/src/containers/book-list.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/book_list/src/actions/index.js b/book_list/src/actions/index.js index e46c223a..95dba608 100644 --- a/book_list/src/actions/index.js +++ b/book_list/src/actions/index.js @@ -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 + }; } diff --git a/book_list/src/containers/book-list.js b/book_list/src/containers/book-list.js index 040f1b60..6683a4f4 100644 --- a/book_list/src/containers/book-list.js +++ b/book_list/src/containers/book-list.js @@ -7,7 +7,12 @@ class BookList extends Component { renderList() { return this.props.books.map((book) => { return ( -
  • {book.title}
  • +
  • this.props.selectBook(book)} + className="list-group-item"> + {book.title} +
  • ); }); }