FAQ: The State Hook - Objects in State

The curly braces surrounding target are for restructuring the event object that is passed to the function. One of the properties on the event object is target, ie. event.target. By restructuring the object we extract the target property for use with our function as the variable ‘target’.

As for the whitespace, it is just for readability.

For more info on destructuring, refer to the MDN page. Destructuring

2 Likes

Over the past few lessons in this module, it has felt to me more and more like they are including esoteric javascript language features in the examples, not because they are necessary, but just because they can. I’m needing to spend more time researching what these do, and how to read the example code, than I am on the actual React concept presented.

  1. Is it expected that anyone working with React is familiar with the kind of code we’re seeing in these examples?
  2. If this is where I’m spending my time, would it make more sense for me to put down React for now, and instead spend my time on all of the language features in Javascript that I’m now seeing which I’ve never had to use before?
2 Likes