Updated event handler for drop down select
This commit is contained in:
13
src/App.js
13
src/App.js
@@ -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() {
|
||||||
|
|||||||
Reference in New Issue
Block a user