https://salesforcegraells.files.wordpress.com/2023/04/image.png?w=772

Introduction

Lifecycle Hooks are functions that are called automatically at a specific time designed to help you manage and manipulate the behavior of a component and its elements, such as when it's about to be created, updated, or destroyed.

These functions allow you to control and manage various aspects of your components at runtime.

Here is the list of all methods:

<aside> ☝ You can find the latest official documentation here: https://lwc.dev/guide/lifecycle

</aside>

Constructor: running code when a component is created

This example is illegal because it adds an attribute to the host element in the constructor().