We're creating a new site and we chose reactjs to do this. And right now I'm researching on events in Javascript and luckily I stumbled on this site where he teaches how to handle events for many elements and letting the parent handle the event and basically is what we are doing for out site as well right now.
As I continued to research, I also stumbled upon this answer here (more react oriented) where it says I would pass the function/method from the parent to the child.
Is it promoting the same way as what was mentioned on the first link? Also, is this the way to do this (like the first link to handle events) in reactjs? Should I implement somewhere along this lines?
Follow up question... or should I ask this separately?
If I have
<Parent>
<ChildComponent>
<ChildComponent>
...
and a child when clicked I add a class to it, say .selected
. But I'd need to remove it to the others since they are not selected anymore. In jQuery I could've done something like
$('.child-components').removeClass('selected');
$(this).addClass('selected');
How to do this the react way?