19

https://facebook.github.io/react/docs/thinking-in-react.html

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
  • 14
    e is the event, which in this case is change, target is the element that triggered the event, which in this case is the input, and value is the value of the input element Commented Aug 10, 2017 at 23:24
  • 1
    I recommend to read quirksmode.org/js/introevents.html . Commented Aug 10, 2017 at 23:29
  • 2
    A slightly confusing thing worth researching is the difference between e.target and e.currentTarget . Reading about the difference may help your understanding. Commented Aug 11, 2017 at 8:49
  • Thank you @Josan , it's more clear now. Thanks for the documentation Felix, I will read it. I will also see that Shammoo. Thanks everybody! Commented Aug 11, 2017 at 16:25

3 Answers 3

14

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

0

So, 'e' stands for event and target is the element that triggered the event. I find pretty useful this explanation about the difference between event.target and event.currentTarget at W3Schools

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.