Added funcaitonality to onSelectChange

This commit is contained in:
Ken Jannette
2018-04-18 16:14:54 -04:00
parent f7dd06e9a8
commit 3e7f683f5c
2 changed files with 7 additions and 2 deletions

View File

@@ -22,8 +22,13 @@ class BooksApp extends React.Component {
} }
onSelectChange = (e) => { onSelectChange = (e) => {
const id = e.target.name
const shelf = e.target.value const shelf = e.target.value
console.log(id, shelf)
this.setState((prevState) => {
prevState.filter(name === book.id)
})
} }
render() { render() {

View File

@@ -6,7 +6,7 @@ class Bookshelf extends Component {
const books = this.props.books const books = this.props.books
const onSelect = this.props.onSelect const onSelect = this.props.onSelect
console.log(books) // console.log(books)
return ( return (
@@ -30,7 +30,7 @@ class Bookshelf extends Component {
<div className="book-top"> <div className="book-top">
<div className="book-cover" style={{ width: 128, height: 193, backgroundImage: `url("${ book.imageLinks.thumbnail }")` }}></div> <div className="book-cover" style={{ width: 128, height: 193, backgroundImage: `url("${ book.imageLinks.thumbnail }")` }}></div>
<div className="book-shelf-changer"> <div className="book-shelf-changer">
<select onChange={onSelect}> <select name={book.id} onChange={onSelect}>
<option value="none" disabled>Move to...</option> <option value="none" disabled>Move to...</option>
<option value="currentlyReading">Currently Reading</option> <option value="currentlyReading">Currently Reading</option>
<option value="wantToRead">Want to Read</option> <option value="wantToRead">Want to Read</option>