I realize this may be a stupid question but I haven't been able to find an explicit explanation anywhere. In my case, I have 2 React components.
Say my main component has a method called doSomethingOnClick(). Now I am calling another component and passing it a prop by calling this method. My question is why do I need to do:
<Component someprop= {(arg) => this.doSomethingOnClick(arg)}
Why can;t I do this instead ?
<Component someprop= {this.doSomethingOnClick(arg)}
Even in the component which receives this prop makes use of a similar syntax. So why do I do
someprop = {(arg) => props.doSomethingOnClick(arg)}
instead of
someprop = {props.doSomethingOnClick(arg)}
The way I understand it is the same method is being called with the same argument leading to the same result. (I hope) Is this something that the syntax simply demands and must be done or is there some special reason for this ?