DEV Community

Discussion on: Understand One-way Data Binding in React the easy way!

Collapse
 
parnikagupta profile image
Parnika-Gupta

Hey there is no particular reason I did that. Is there a reason why we should or shouldn't be using arrow functions when we can directly pass the setText function? I would love to learn more about the depth of it.

Collapse
 
r4e profile image
Richie Permana

IMHO, its just matter of simplicity and consistency.

<Child setText={ setText }>
// is the same as
<Child setText={(text) => { setText(text) }}>

// but not as
<Child setText={ setText() }>
//or
<Child setText={(text) => setText(text)}>
Enter fullscreen mode Exit fullscreen mode

CMIIW.

Thread Thread
 
parnikagupta profile image
Parnika-Gupta

I just saw a video on callbacks that made it clear for me.. I will find it again to grab a link and share if anyone needs...But what's the difference between 2nd format and the 4th one that you have shared?

Collapse
 
salarc123 profile image
SalarC123

I’m not actually sure. I’ve just always done it like this, but I don’t really see any differences between the two methods