Added setState call in app.js
This commit is contained in:
10
src/App.js
10
src/App.js
@@ -18,16 +18,18 @@ class BooksApp extends React.Component {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
getAll().then((books) => {
|
getAll().then((books) => {
|
||||||
this.setState({ books })
|
this.setState({ books })
|
||||||
console.log(this.state.books[0].id)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectChange = (e) => {
|
onSelectChange = (e) => {
|
||||||
const id = e.target.name
|
const id = e.target.name
|
||||||
const shelf = e.target.value
|
const newShelf = e.target.value
|
||||||
// console.log(id, shelf)
|
console.log(id, newShelf)
|
||||||
const changeShelf = this.state.books.filter((book, id) => book.id === id)
|
const changeShelf = this.state.books.filter((book) => { return book.id === id})
|
||||||
console.log("changeShelf: ", changeShelf)
|
console.log("changeShelf: ", changeShelf)
|
||||||
|
this.setState({
|
||||||
|
changeShelf.shelf: changeShelf.newShelf
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
Reference in New Issue
Block a user