2

I am new to lightning and i just dont get renderer. Why do we use it? Can please anyone tell me with example. I get the part that salesforce automatically renders if some data is changed. But why use after that?

1
  • Whenever you embed a component in aura:if and condition becomes false then component gets removed. In such case if you want to run some logic when component is destroyed like removing the setInterval that you have added and you want to remove that once the component is destroyed. – Kiran Machhewar Jun 26 '18 at 22:27
3

We have dozens of components and none of them have a renderer. Most of the time you don't need to have one so don't concern yourself until you find a reason to add one. And in my experience, when you think you have a reason, an alternative solution might well be cleaner: best to leave the DOM manipulation to the framework and work with components not DOM elements.

The documentation says:

Custom Renderer

You don’t normally have to write a custom renderer, but it’s useful when you want to interact with the DOM tree after the framework’s rendering service has inserted DOM elements. If you want to customize rendering behavior and you can’t do it in markup or by using the init event, you can create a client-side renderer.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.