What is connected callback vs. rendered callback in the lightning web component?

912    Asked by Dannasahi in Salesforce , Asked on Aug 24, 2023

Salesforce LWC is a vast topic. That is why I am finding that understanding the LWC component lifecycle methods is crucial and difficult. Can anyone help me understand what connected callback and rendered callback are? 

Answered by Diana Campbell

The connected callback vs. rendered callback is essential to understand the Salesforce LWC. You need to understand the difference between the two. Firstly, the connected callback is executed when it is provided to DOM. The connected callback () hook can be executed more than once. For example, when you reorder a list, it gets fired multiple times. Also, if you want it to stop being executed more than once, you need to write to code.

On the other hand, when rendered, callback is invoked when the elements on the component are provided. One of the best examples of rendered callback is that it is used to load static resources.

Your Answer


Parent Categories