r/reactjs • u/acemarke • May 03 '18
Beginner's Thread / Easy Question (May 2018)
Pretty happy to see these threads getting a lot of comments - we had over 200 comments in last month's thread! If you didn't get a response there, please ask again here!
Soo... Got questions about React or anything else in its ecosystem? Stuck making progress on your app? Ask away! We’re a friendly bunch. No question is too simple.
The Reactiflux chat channels on Discord are another great place to ask for help as well.
25
Upvotes
View all comments
Show parent comment
3
u/brncbb May 04 '18
I'm guessing
onVideoSelectlooks something like:The problem with having
is that it will execute the body of that function every time the component is rendered -- it's assigning the
onClickproperty of thelielement to whatever is returned inside the{}.If you'd prefer to omit the arrow function, Function.prototype.bind can be your friend.
returns a function that, when called, will execute
props.onVideoSelectwithprops.videoas its first argument, and withthisinside that function bound to whateverthisis inside the{}.So you may be able to do