Reputation: 1928
On Facebook's React tips page Communicate Between Components they show an example using javascript's bind() to pass arguments to the parent's handleClick() method.
This works well, except using bind the first argument of an event handler is no longer the event that was triggered. I'd still like access to the event so what are my options in this regard?
Upvotes: 5
Views: 411
Reputation: 255005
You just specify it as
onClick={e => this.handleClick(e, i)}
That way you create a new anonymous function that both passes the original event and your custom data.
Upvotes: 3