While preparing myself to the Developer 1 certification I met the following question:
A developer created a lightning component named
accountList.cmp that displays a list of Accounts. Client side logic that is executed when a user hovers over an Account in the list should be stored in which
I answered C), while the correct answer is D).
I am working with Lightning and I always delegate as much logic as I can from the controller to helper. And the button listeners which get executed are always in the controller, but since I do not see the controller option in the answers I stick to helper, which is C).
I consider the renderer to be something which is responsible for displaying components. So, if possible, could you please provide the resource to research the topic further and explain the answer to the question?
On top of my head, On Hover is similar to DOM manipulation. Due to lightning locker services if you do dom manipulation in helper which is called from controller you get exceptions as it is not allowed.
Dom manipulation is always allowed in after renderer, so accountListRenderer seems the best option.
But But But.. if you see the method signature of afterRenderer
you can call helper method from the renderer, so technically helper is the best place to write that code, and it should be called from renderer and not the controller.