The Node.isConnected property, which returns a Boolean indicating whether the component is connected to the DOM. Simply use this.isConnected in a component’s JavaScript.
import { LightningElement } from 'lwc'; export default class MyComponent extends LightningElement { someMethod() { const cmp = this; const aPromise = new Promise(tetherFunction); aPromise.then((result) => { if (cmp.isConnected) { // Update the component with the result. } else { // Ignore the result and maybe log. } }) } }
No comments:
Post a Comment