Chapter 4. The component lifecycle

This chapter covers

  • Using the connectedCallback Web Components API method to listen when your component is added to the DOM
  • Knowing when and how to use the constructor method, especially because it occurs before the component has access to the DOM
  • Utilizing the disconnectedCallback Web Components API method to clean up after your component
  • The seldom-used adoptedCallback Web Components API method

4.1. The Web Components API

Up to now, we’ve explored a couple different methods from the Web Components API, but we really didn’t talk about the API as a whole. These methods are the basic building blocks for building everything from custom components to entire applications. So, it’s a good idea to take a look ...

Get Web Components in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.