alamba78 (17) [Avatar] Offline
#1
So, I'm looking at the topic on destructuring props and state and in Listing 2.12 we have this line of code:

 const { book } = this.state 


should this rather be:

 const { book } = this.state.book 


Or is it ok to use this.state when there is only one property variable in state?
287516 (45) [Avatar] Offline
#2
So with destructuring, when referencing an object you basically have access to all properties of the object on the left hand assignment.

For instance, if we have:

const book = { name: 'Ready Player One', author: 'Ernest Cline' }


We could destructure author and name like this:

const { name, author } = book