E. Target. Value on an Input Field Reactjs, How Does It Work?

E. Target. Value on an Input Field Reactjs, How Does It Work?

I'm at the end of this tutorial and I'm just not understanding how e.target.value works. Walk through the end of this tutorial and see the sample code that there is please. I'm newbie both to React and Javascript.

4

2 Answers

The e is the argument of an event handler you attach to a certain event on a certain component... in this case the onFilterTextInput event. Events are objects with certain properties, and e.target almost always represents a DOM element.

Thus e.target.value is the value property of some DOM element, in this case that means the text entered in the search input.

When you need to handle multiple controlled input elements, you can add a name attribute to each element and let the handler function choose what to do based on the value of event.target.name. By React DOC

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.