function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Akhil Katkam 5Akhil Katkam 5 

how to write aura : handler in lwc

Hi Developer Community,

I am currently working on a task and It requires LWC,
So my problem is , how can i write aura:handler method in LWC

for example:

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

This above example need to be written in LWC,

Can u please help me with this problem

Thanks in Advance

 

 

ANUTEJANUTEJ (Salesforce Developers) 
Hi Akhil,

>> https://developer.salesforce.com/docs/component-library/documentation/en/lwc/migrate_initializers

As mentioned in the above link, you can use connected call back in lightning web components for using init equivalent in lwc.

Below is a snippet mentioned in documentation for quick reference:
 
// mySampleInit.js
import { LightningElement } from 'lwc';
export default class MySampleInit extends LightningElement {
    connectedCallback() {
        // initialize component
    }
}

>> https://salesforcediaries.com/2019/09/29/onload-in-lightning-web-component/

The above link has implementations for using connected callback in lwc.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
sreenath reddy 21sreenath reddy 21
Hi Akhil
You can use connectedCallback() in LWC
Please go through below link you have idea how to use it
https://salesforcediaries.com/2020/04/30/onload-in-aura-vs-lightning-web-component/