
1. What is a Lightning Web Component (LWC)?
Lightning Web Component is a Salesforce programming model that utilizes modern web standards for developing components on the Salesforce Lightning Platform.
2. What are the key features of Lightning Web Components?
Key features include reusability, encapsulation, performance optimization, and alignment with modern web standards.
3. How do you pass data from a parent component to a child component in LWC?
Data is passed from a parent to a child component using properties marked with the @api decorator in the child component.
4. How can you handle events in LWC?
Events can be handled using the @wire decorator, which links a component’s property to a value from an Apex method.
5. What is the purpose of the @wire decorator in LWC?
The @wire decorator is used to connect a component’s property to a data source, such as an Apex method or a record field.
6. What is the role of the Lightning Data Service (LDS) in LWC?
Lightning Data Service offers a standard approach to accessing and managing Salesforce data in Lightning Components, including LWC.
7. How do you make an HTTP callout from a Lightning Web Component?
The fetch API is used for HTTP callouts in LWC. Import the fetch method to send requests to external services.
8. What is the use of the @track decorator in LWC?
The @track decorator monitors property changes to enable the component to rerender when those properties are updated.
9. How do you handle errors in Lightning Web Components?
Utilize the try–catch block to capture and manage errors, and display error messages to users as needed.
10. What is the difference between lightning-card and lightning-layout components in LWC? The lightning-card offers a styled container for content, whereas lightning-layout sets up layouts with multiple regions.
11. Explain the concept of shadow DOM in LWC.
Shadow DOM is a web standard that encapsulates a component’s styles and structure, preventing CSS clashes with other components on the page.
12. What is the role of the wire service in LWC?
The wire service is a module providing reactive data binding, allowing data fetching and updates without writing extensive code.
13. How do you handle user interactions in LWC?
Use event handlers in the template to listen for user interactions, like clicks or inputs, and trigger methods in the component’s JavaScript.
14. What is the purpose of the api property in LWC?
The api property exposes properties and methods in a Lightning Web Component that can be utilized by parent components or external code.
15. What is the difference between imperative and reactive Apex methods in LWC?
Imperative methods use @wire to fetch data as needed, while reactive methods use the @wire service to update data automatically when changes occur.
16. How can you make a Lightning Web Component available for use in the Salesforce App Builder? Define a custom component in the meta.xml file of your LWC and set the isExposed attribute to true.
17. What is the purpose of the lightning-record-edit-form component in LWC?
The