I’m curious about how a React handleChange(event) function can use object destructuring to use ({target}) as an argument like this (the bottom example):
Why can the target become an object? Any help would be greatly appreciated. Thanks!
I’m curious about how a React handleChange(event) function can use object destructuring to use ({target}) as an argument like this (the bottom example):
Why can the target become an object? Any help would be greatly appreciated. Thanks!
These are – once again – Javascript basics, nothing React specific. event
is an object and target is its property. And you can destructure properties of objects like this in Javascript – and therefore in React. And target doesn’t become an object – it is an object if the element that dispatched the event is one.
More about JS events can be found in the MDN docs