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) => { onSelectChange = (e) => {
const id = e.target.name const id = e.target.name
const newShelf = e.target.value const newShelf = e.target.value
console.log(id, newShelf) // console.log(id, newShelf)
let changeShelf = this.state.books.filter((book) => { return book.id === id}) let changeShelf = this.state.books.filter((book) => { return book.id === id})
console.log("changeShelf: ", changeShelf) const books = this.state.books.slice(); // Create local copy to change.
this.setState({ books.forEach((book) => {
if (book.id === id) {
}) book.shelf = newShelf;
}
});
this.setState({ books });
} }
render() { render() {