Im quite new to React and have created a new view at my company. I use inline functions because many guides do the same. Everything is written as function components.
I write onClick like this:
onClick: () => onBackClick()
My co-workes says this is a usless arrow function.
Will try to give you the whole picture. Parent component has the onBackClick function declared
const Parent = () => {
const onBackClick = () => {backOff}
<Child {...{onBackClick}}/>
}
const Child = ({onBackClick}) => {
return (
<MyButton {...{onClick: () => onBackClick() }}/>
)
}
My co-workers want me to write it like this:
onClick: onBackClick
I dont get a good explanation on why and really would like to learn. Can someone be kind to explain why this is a better way to write it.
Regards.