Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 802 Bytes

no-async-operation.md

File metadata and controls

33 lines (25 loc) · 802 Bytes

Restrict usage of async operations (no-async-operation)

Asynchronous operations make it difficult to track page performance. In most cases, you can use a lifecycle hook instead.

Rule details

Example of incorrect code:

import { LightningElement } from 'lwc';

export default class Foo extends LightningElement {
    connectedCallback() {
        setTimeout(() => {
            const el = this.template.querySelector('span');
            // ... manipulating the span LightningElement
        });
    }
}

Example of correct code:

import { LightningElement } from 'lwc';

export default class Foo extends LightningElement {
    renderedCallback() {
        const el = this.template.querySelector('span');
        // ... manipulating the span LightningElement
    }
}