Skip to main content

DOM

Explore practical guides and implementation patterns for this topic.

Posts

Lightning Web Components

LWC Template & Rendering Fundamentals: Master the Salesforce UI

💬 In Plain Words: An LWC template is essentially standard HTML powered by a few specialized directives. You use lwc:if to conditionally show or hide elements, for:each to loop through data (always providing a unique key ), and {property} syntax to bind data from your JavaScript class. Rendering in LWC is strictly one-way : when the JavaScript data changes, the screen automatically updates. You should almost never manipulate the DOM manually. 📌 The Strategy Example: Using lwc:if={isLoading} displays a loading spinner while data fetches. When looping over a list of support cases using for:each , you must use key={case.Id} . Never use the loop index as the key. If you do, reordering the list will force the browser to rebuild the entire DOM, causing you to lose user focus and destroy performance.
Read article