Lightning Web Components Flashcards
Lightning Web Components Open Source vs. Lightning Web Components (On Platform)
1. Feature Availability - OSS will get access to features sooner because of the release schedule. And also because of the integration with the Salesforce that needs to be developed.
- LWC OSS - updates once a week
- LWC - 3 updates a year
2. Development Environment
- LWC OSS - no prefered environment
- LWC - Salesforce Extention Pack for VS Code + Salesforce CLI
3. Custom Componenet Namespace
- LWC OSS - ability to control namespaces
- LWC - created in default c namespace
4. Standard Components
- LWC OSS - no access by default to standard components
- LWC - access to all components
5. SLDS
- LWC OSS - don’t include SLDS by default
- LWC - no prior setup needed
6. Working with Salesforce Records
- LWC OSS - make use of Salesfor API
- LWC -
What are the requirements for a web component bundle (for a visible element)?
Meta XML file
HTML template
Javascript module
What is a Meta XML file?
- includes information about the API version they should be used with
- determines where within our org that component can be surfaced
What are template directives?
template directives allow us conditionally render markup (if:true and if:false) or to iterate through collections, rendering markup for each element of the collection (for:each and iterator)
How can we data bind or action bind?
we can data bind or action bind by surrounding the variable name in our HTML template with curly braces to bind it to a property or method within the component’s JS moduonle
onchange={handleChange}
How do we instantiate a lwc inside of another?
to instantiate a component inside of another, we follow the kebab case naming convention with the format
What does the Shadow DOM do?
it implements encapsulation so that the inner content of a component cannot be accessed by entities outside of the component bundle by default
What are the three LWC Decorators that come with the framework?
- @track
- @wire
- @qpi
What is the @track decorator?
- allows us to make objects and arrays in our JS reactive
- this means that our component will automatically rerender whenever the contents of a collection with the track decorator is changed
What is the @wire decorator?
- allows us to have the framework handle the invocation of methods from our org or other external services
What is the @api decorator?
- we’ll apply the @api decorator to any variable or method within our JS class that we’d like to expose publicly
Lightning Web Component Lifecycle for Composed Components
- Invoke constructor connected callback on the parent
- Then we go all the way down to any children constructor and invoke the connected call back on them
- only when the rendered callback has been invoked on all children of a particular component do we have it invoked on the parent component itself
- and then we use the disconnectedCallback() whenever we are removing a component from the DOM
What is a constructor()?
- the constructor() callback is invoked when a component is instantiated
What is a connectedCallback()?
invoked whenever a component is inserted into the DOM
What is a renderedCallback()?
invoked whenever a component is rendered