Monday, December 19, 2022

Create Lightning Web Components

A Lightning web component is a reusable custom HTML element with its own API.
  • Define a Component
    A Lightning web component that renders UI must include an HTML file, a JavaScript file, and a metadata configuration file. The files must use the same name so the framework can autowire them. A service component (library) must include a JavaScript file and a metadata configuration file.
  • HTML Templates
    The power of Lightning Web Components is the templating system, which uses the virtual DOM to render components smartly and efficiently. It’s a best practice to let LWC manipulate the DOM instead of writing JavaScript to do it.
  • CSS
    To give your component the Lightning Experience look and feel, use Lightning Design System. To go your own way, write your own CSS.
  • Composition
    You can add components within the body of another component. Composition enables you to build complex components from simpler building-block components.
  • Fields, Properties, and Attributes
    Declare fields in your component’s JavaScript class. Reference them in your component’s template to dynamically update content.
  • JavaScript
    Every component must have a JavaScript file. JavaScript files in Lightning web components are ES6 modules.
  • Access Static Resources, Labels, Internationalization Properties, User IDs, and Form Factors
    Lightning components can access global Salesforce values, such as labels, resources, and users.
  • Component Accessibility
    Accessible software and assistive technologies enable users with disabilities to use the products you build. Develop your components so that all users can perceive, understand, navigate, and interact with them.
  • Component Lifecycle
    Lightning web components have a lifecycle managed by the framework. The framework creates components, inserts them into the DOM, renders them, and removes them from the DOM. It also monitors components for property changes.

No comments:

Post a Comment