
1. What is a Lightning Web Component (LWC)?
A Lightning Web Component is a Salesforce programming model that uses modern web standards to build components for 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, annotated 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 wires 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 method to access and manipulate Salesforce data in Lightning Components, including LWC.
7. How do you make an HTTP callout from a Lightning Web Component?
Use the fetch API to make HTTP callouts in LWC by importing and utilizing it to send requests to external services.
8. What is the use of the @track decorator in LWC?
The @track decorator tracks changes to properties so that the component can rerender upon property changes.
9. How do you handle errors in Lightning Web Components?
Use try–catch blocks to catch and handle errors gracefully, and display error messages to users.
10. What is the difference between lightning-card and lightning-layout components in LWC? lightning-card provides a styled container for content, while lightning-layout is used for creating layouts with various 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 conflicts with other components.
12. What is the role of the wire service in LWC?
The wire service is a module offering reactive data binding, allowing data retrieval and updates from a data source without boilerplate code.
13. How do you handle user interactions in LWC?
Use event handlers in the template to listen to user interactions, like clicks or inputs, and call 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 for use 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 automatically update data upon changes.
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?
lightning-record-edit-form is used to create, view, or edit a record’s fields using