Reputation: 41
I've attached event listener with onClick
property like this:
<a href="#" onClick={function (event) {
console.log(arguments.length); // prints 2
// arguments[0] = SyntheticEvent - it's ok
// arguments[1] = undefined - what is this???
}}>Click me</a>
The event listener called with 2 arguments: synthetic event and strange undefined value.
I think, normal behavior is when handler called with a single param - event object.
Windows 10. Chrome 53. React version - 15.2.0.
Upvotes: 1
Views: 207
Reputation: 12074
The second argument is the key which react gives to elements when you didn't provided your key.
React will automatically use an increasing integer number for the key.
React will determine whether it is the same component or not based on that key.
In this jsfiddle you can see if you click on first link that key is 0.0 and if you click on the second one that key is 0.2 because <br/>
has a key of 0.1.
Upvotes: 1