Understanding the rendering life cycle of a component

The following diagram shows the sequence of events that happens from component instantiation to component rendering:

It's always preferable to use a framework render event to perform custom logic, such as DOM manipulation, instead of overriding the render function.

In order to further understand, let's create a Lightning application with the following code, and observe some logs in the console. We'll call the sample application LifeCycleExampleApp.app:

<aura:application extends="force:slds">  <aura:handler name="init" value="{!this}" action="{!c.onInit}"/> <aura:handler name="render" value="{!this}" ...

Get Learning Salesforce Lightning Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.