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
What is disconnectedCallback()?
invoked whenever the component is removed from the DOM
What is errorCallback()?
invoked whenever we have some sort of exception occur within a child component
What handles the Client Side Security?
- client-side security is taken care of for us through Lightning Locker
- lightning locker allows the LWC framework to wrap each component in its own shadow tree
What is the order of preference for working with Salesforce data?
- Use standard components from the Lightning Component Library with Lightning Data Service
- Use wire adapters with Lightning Data Service
- Use wire adapters with Apex methods
- Imperatively invoking Apex methods
Syntax to import an object into our JS class
import OBJECT_NAME from ‘@salesforce/schema/ObjectApiName’;
Syntax to import a field into our JS class
import FIELD_NAME from ‘@salesforce/schema/ObjectApiName.FieldApiName’;
What is the Lightning Data Service? (What preference is it?)
- Lightning Data Service is a Salesforce feature that allows us to interact with our records without needing to write much, if any, non-markup code
- Lightning Data Service is the fastest and most efficient way to work with our Salesforce records
- if multiple components are working with the same record, Lightning Data Service will only query for the record a single time and update the record in all components that reference it whenever changes
- Lightning Data Service caches the record locally so that unnecessary server calls aren’t made
What are the three components for Lightning Data Service available to LWC?
- add, view, update a record
- displays record data
- used to add record or update fields on existing records
What are Wire Service?
- the wire service allows us to retrieve data for a Lightning web component by invoking a method from Lightning Data Service, an Apex method, or a method from another JS module
- to use the wire service, we need to import the wire decorator from the lwc module