Loading tutorials
connectedCallback() runs when the browser inserts a component into the DOM. It is the standard place to start work that depends on the component's inputs or its environment. This chapter assumes you can write a Lightning Web Component (LWC) with an HTML template and a JavaScript class, and that yo5 min readrender() sits among the other hooks. You have already seen constructor() and connectedCallback(). Here you will learn what render() d7 min read{expression} syntax, and that connectedCallback() and renderedCallback() exist. You don't need to know how the reactivity system works internally6 min readrenderedCallback(), the hook that runs after a component's template has been turned into DOM. It assumes you can write a basic Lightning Web Component (an HTML template plus a JavaScript class). It also assumes you know that fields used in a template are reactive, and that you 6 min readconstructor(), connectedCallback(), renderedCallback() and disconnectedCallback() do for one component. Here the question changes from "when does my hook run?" to "when7 min readconnectedCallback(), you know that this.template is the component's shadow root, and you have used addEventListener in plain JavaScript. The earlier chapters on connectedCallback() and renderedCallback() cover the setup half of the lifec7 min readconnectedCallback() and disconnectedCallback() run when a component enters and leaves the DOM. It also assumes you are comfortable with basic JavaS6 min readerrorCallback(), the hook that lets a component handle errors thrown by its descendants. It assumes you know basic JavaScript classes and ES modules, how to build an LWC with an HTML template and a JavaScript class, how reactive fields and template expressions work, and how DOM5 min read