I want to call two functions passes via props on click. Note that both of them need arguments of their own. After a bit of searching on Stack Overflow, I found this solution:
onclick={()=>{ f1(); f2() }}
So I implemented mine as follows:
onClick={() => {f1(arg); f2.bind(this, arg)}}
But the second function never gets called. Can anyone please explain why this isn't working? I'm assuming its some binding issue?
f1 is in the parent component:
f1(arg, event)
{
event.preventDefault();
// so on...
}
f2 is also in the parent argument as follows:
f2(arg)
{
// do something with the argument
}
They are getting passed to the child component
render()
{
const { f2, arg, f1 } = this.props;
return(
<button onClick={() => {f2(arg); f1.call(this, arg)}}>
)
}