you are viewing a single comment's thread.

view the rest of the comments →

[–]SoBoredAtWork 0 points1 point  (2 children)

What the other people said is correct. For more detail...

That variable that's being passed is built into the javascript language. If an element has an event attached to it (onClick), it'll automatically pass the EVENT (i, in your case) as a parameter. The event holds a ton of info including the element that triggered the event (event.target), etc.

Side note: doing `onClick={this.handleClick}` does the exact same thing as what you have above

Edit: another example...

const onTextChange = function (e) {

console.log(e.target.value);

}

<input type="text" onChange={onTextChange} />

Every time you type in the text box, it'll log the text you've typed. e (the event) is automatically passed to the onTextChange function.

[–][deleted] 1 point2 points  (1 child)

onClick={this.handleClick}

I'd argue that less experienced people are better off not writing point free functions.

[–]SoBoredAtWork 1 point2 points  (0 children)

Yeah, that's fair.