HackerNoon Mobile

Better reading experience on the app
A Guide to Handling Web Component Removal With DisconnectedCallbackby@raymondcamden

A Guide to Handling Web Component Removal With DisconnectedCallback

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

MDN does a fairly good job of covering the lifecycle events for web components but one in particular got my attention today, disconnectedcallback. As kind of the inverse of connectedCallback, it will be fired when an instance of your custom element is removed from the DOM. While I didn't doubt this worked as advertised, I wanted to build a quick demo myself so I could see it in action. Let's start off with a component that demonstrates why this event is needed.
featured image - A Guide to Handling Web Component Removal With DisconnectedCallback
Raymond Camden HackerNoon profile picture

@raymondcamden

Raymond Camden


Receive Stories from @raymondcamden


Credibility

react to story with heart
Raymond Camden HackerNoon profile picture
by Raymond Camden @raymondcamden.Father, husband, web nerd who builds too many cat-based demos. Love Jamstack, serverless, JavaScript, Python.
Read my stories

RELATED STORIES

L O A D I N G
. . . comments & more!