Updated event handler for drop down select

This commit is contained in:
Ken Jannette
2018-04-19 12:07:02 -04:00
parent 441a396aa7
commit c5cafde555

View File

@@ -24,12 +24,15 @@ class BooksApp extends React.Component {
onSelectChange = (e) => {
const id = e.target.name
const newShelf = e.target.value
console.log(id, newShelf)
// console.log(id, newShelf)
let changeShelf = this.state.books.filter((book) => { return book.id === id})
console.log("changeShelf: ", changeShelf)
this.setState({
})
const books = this.state.books.slice(); // Create local copy to change.
books.forEach((book) => {
if (book.id === id) {
book.shelf = newShelf;
}
});
this.setState({ books });
}
render() {