Skip to content

disconnected

disconnected is a DOM event that occurs whenever any webcomponent in Storefront gets disconnected thus firing the disconnectedCallback Lit lifecycle method.

Event body

none

Example

In this example we listen to disconnected event on a product-review webcomponent and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    const $productReview = document.querySelector('product-review');

    $productReview.addEventListener('disconnected', () => {
        console.log('Reviews have been disconnected');
    });
});