LWC interview questions
LWC interviews check that you can build a component from its three files, pass data between a parent and a child, and load Salesforce data without blocking the UI. Expect questions on @api and @wire, custom events, the lifecycle hooks the framework calls, and how a component reads and writes through Apex. The full tutorial stays on the Lightning Web Components guide.
Questions and short answers
What is a Lightning web component?
A Lightning web component is a standard web component that runs on the Lightning platform. You write a JavaScript class that extends LightningElement, an HTML template, and an XML meta file that says where the component can sit. The three files share the folder name, and the meta file also controls whether the component shows up in App Builder.
What do @api and @wire do?
@api marks a property or method as public, so a parent component or App Builder can set or call it. @wire connects the component to Salesforce data, such as a cacheable Apex method or a UI API adapter, and re-runs when its reactive inputs change. Both decorators come from the lwc module, which you import at the top of the class.
@api, @track, and @wire Wire service
How does a parent pass data to a child?
The parent sets an @api property on the child tag. The child reads that property. It does not reach up and change the parent's fields.
How does a child tell its parent that something happened?
The child dispatches a CustomEvent. The parent listens with an on-prefixed handler on the child tag. Add bubbles or composed only when a listener on the child is not enough.
Which lifecycle hooks does the framework call?
The framework calls constructor first, then connectedCallback when the component is inserted into the DOM, renderedCallback after every render, and disconnectedCallback when it is removed, plus errorCallback when a descendant throws. connectedCallback is where most components start loading data, and renderedCallback can run more than once, so work that must happen only once needs a guard.
How does a component call Apex?
Read with a cacheable method and @wire. Save with an imperative call, because a wire must not perform DML. Use the UI API when you do not need a custom Apex class.