paint-brush
A Guide to Handling Web Component Removal With DisconnectedCallbackby@raymondcamden
240 reads

A Guide to Handling Web Component Removal With DisconnectedCallback

by Raymond Camden3mJune 8th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

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
Raymond Camden

Raymond Camden

@raymondcamden

Father, husband, web nerd who builds too many cat-based demos. Love Jamstack, serverless, JavaScript, Python.

0-item

STORY’S CREDIBILITY

Code License

Code License

The code in this story is for educational purposes. The readers are solely responsible for whatever they build with it.

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

About Author

Raymond Camden HackerNoon profile picture
Raymond Camden@raymondcamden
Father, husband, web nerd who builds too many cat-based demos. Love Jamstack, serverless, JavaScript, Python.

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Also published here