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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With