๐Ÿš€50 Real-Time LWC Scenario Q&A (2025) | Complete Salesforce Developer Guide

Published On: November 30, 2025

Lightning Web Components (LWC) continues to dominate Salesforce development in 2025.
Whether you’re preparing for a Salesforce Developer interview or building complex UI solutions,
scenario-based questions are the MOST asked.

This blog covers 50 real-time LWC scenario-based interview questions in a structured format:

๐Ÿ‘‰ What they asked me
๐Ÿ‘‰ What I said
๐Ÿ‘‰ Tips / Best practices

These answers reflect actual project-level examples, updated LWC patterns, UI API, Apex best practices, and 2025 interview standards.


๐Ÿ“Œ Table of Contents

  1. Component Communication
  2. Data Handling & Refreshing
  3. UI Rendering & Modals
  4. Apex Integration
  5. LDS/UI API
  6. Datatables & Forms
  7. Pagination & Search
  8. Performance Optimization
  9. Navigation & Validation
  10. Real-Time Integrations
  11. Error Handling & Testing
  12. File Upload, Picklists, Messaging
  13. 10+ Additional Real-Time Scenarios

1. Parent โ†’ Child & Child โ†’ Parent Communication

Table of Contents

What they asked me

โ€œHow do you pass data between parent and child LWCs?โ€

What I said

I explained both directions clearly:

Parent โ†’ Child (using @api)

// parent.html
<c-child info={accountInfo}></c-child>

Child โ†’ Parent (using CustomEvent)

// child.js
this.dispatchEvent(
    new CustomEvent("update", {
        detail: { city: this.city, postal: this.postal }
    })
);

Tips

  • Use @api for public properties.
  • Use events for upward communication.
  • Use LMS for cross-page or Aura โ†” LWC communication.

2. Cross-DOM Communication (Unrelated Components)

What they asked me

โ€œIn your project how did two LWCs on different pages talk to each other?โ€

What I said

Using Lightning Message Service (LMS):

publish(this.messageContext, SAMPLE_MC, { data: this.value });

Tips

LMS works across:

  • LWC โ†” LWC
  • LWC โ†” Aura
  • LWC โ†” Utility Bar
  • LWC โ†” Flows

3. LWC Not Refreshing After DML

What they asked me

โ€œApex ran DML but the UI didnโ€™t refresh. What did you do?โ€

What I said

In older pattern:

refreshApex(this.wiredList);

Modern way (2025):

import { refresh } from 'lightning/uiRecordApi';
refresh(this.recordWire);

Tips

Always mention refresh wire adapter โ€” interviewers expect 2024+ answer.


4. Re-fetching Only Changed Data

What they asked me

โ€œHow did you avoid reloading full data after DML?โ€

What I said

I used:

  • LDS partial refresh
  • refresh(recordApi)
  • Apex selective SOQL queries (fetch only affected part)

Tips

Never reload all data blindly.


5. Imperative Apex Call With Error Handling

What they asked me

โ€œHow do you call Apex on button click with error logging?โ€

What I said

Used async/await:

try {
   const result = await updateContact({ conId: this.recordId });
} catch(error) {
   this.showToast('Error', error.body.message, 'error');
}

Tips

Mention:

  • centralized error handler
  • Platform logging
  • ShowToastEvent

6. Handling Multiple Apex Calls Together

What they asked me

โ€œHow do you handle multiple dependent Apex calls?โ€

What I said

Parallel:

Promise.all([getAcc(), getCon(), getCases()])

Sequential (if dependent):

const acc = await getAcc();
const con = await getCon({ accId: acc.Id });

Tips

Explain spinner & exception handling.


7. Inline Edit + Row Actions

What they asked me

โ€œHow did you implement inline edit in datatable?โ€

What I said

Save inline edits:

handleSave(event) {
  updateRecords({ data: event.detail.draftValues })
    .then(() => refreshApex(this.wiredData));
}

Tips

Mention:

  • draftValues
  • onsave event
  • Refresh strategy

8. Custom LWC inside Datatable Cell

What they asked me

โ€œHow did you pass row-wise record Id to custom cell LWC?โ€

What I said

{ 
   type: 'customCell',
   typeAttributes: {
      recordId: { fieldName: 'Id' }
   }
}

Tips

Use LightningDatatable extended.


9. When Should You Use UI API Instead of Apex?

What they asked me

โ€œTell a real scenario where you replaced Apex with LDS.โ€

What I said

I explained I replaced Apex when:

  • Only single record fetch
  • CRUD/FLS needed
  • No complex SOQL

Example:

import { getRecord } from 'lightning/uiRecordApi';

Tips

Mention: UI API = auto FLS + faster + cached.


10. Custom Validation Before Submit

What they asked me

โ€œHow did you stop form submission if validation fails?โ€

What I said

this.template.querySelector("lightning-input")
 .setCustomValidity("Invalid postal code");

Then:

input.reportValidity();

Tips

LWC validation > Aura validation (cleaner).


11. Dynamic Picklist Without Apex

What they asked me

โ€œHow did you load dependent picklists?โ€

What I said

getPicklistValuesByRecordType

Which returns controllerโ€“dependent metadata.

Tips

NO Apex needed for picklists now.


12. Server-Side Pagination

What they asked me

โ€œHow did you handle large data (>50k records)?โ€

What I said

Approach:

  • SOQL with LIMIT/OFFSET
  • Apex returns 50 records per page
  • LWC controls next/prev page

Tips

Discuss limits:

  • OFFSET Max = 2000 rows
  • For big data โ†’ QueryMore pattern

13. Debounced Search Bar

What they asked me

โ€œHow did you avoid multiple Apex calls during search?โ€

What I said

clearTimeout(this.delayTimer);
this.delayTimer = setTimeout(() => {
   this.searchData();
}, 400);

14. LWC Performance Techniques

What they asked me

โ€œWhat did you do when your component loaded slowly?โ€

What I said

I applied:

  • Debounce
  • UI API caching
  • Lazy load JS (import module dynamically)
  • Reduce DOM renders
  • Limit reactive variables
  • Used Pagination

Tips

Mention Shadow DOM performance.


15. Navigation to Record / List / Object

What they asked me

โ€œHow do you navigate from LWC?โ€

What I said

Use NavigationMixin.

Example:

this[NavigationMixin.Navigate]({
    type: 'standard__recordPage',
    attributes: { recordId, actionName: 'view' }
});

16. Live Data Sync

What they asked me

โ€œHow do you refresh UI automatically when a record changes?โ€

What I said

Using:

  • Change Data Capture (CDC)
  • CometD
  • LMS

17. LWC Error Boundary

What they asked me

โ€œHow do you catch component-level errors?โ€

What I said

errorCallback(error, stack) {
    console.error(error, stack);
}

18. File Upload Handling

What they asked me

โ€œHow did you upload files to a record?โ€

What I said

Used:

<lightning-file-upload record-id={recordId}></lightning-file-upload>

Or custom Apex for ContentVersion.


19. Testing LWC With Jest

What they asked me

โ€œHow do you mock wire services?โ€

What I said

Use:

jest.mock('lightning/uiRecordApi');

Then verify DOM after re-render.

20. Preventing Double Submit in LWC

What they asked me

โ€œIn your LWC, when the user clicked the button twice, the Apex method ran twice. How did you prevent double-submit?โ€

What I said

I used an isLoading boolean to disable the button immediately after first click.

<lightning-button 
    label="Save"
    disabled={isLoading}
    onclick={handleSave}>
</lightning-button>
handleSave() {
    this.isLoading = true;
    saveData({ recordId: this.recordId })
        .then(() => { this.showToast('Success'); })
        .finally(() => { this.isLoading = false; });
}

Tips

  • Disable button on first click
  • Show spinner during operation
  • Server should also block duplicate operations

21. Using Shared JavaScript Utility Across Multiple LWCs

What they asked me

โ€œYour project had repetitive formatting logic. How did you avoid duplicate code across components?โ€

What I said

I created a shared JS module under /modules/utility/formatter.js, then imported it across LWCs.

// modules/utility/formatter.js
export function formatPhone(phone) { ... }

Usage:

import { formatPhone } from 'c/formatter';

Tips

  • Shows clean architecture thinking
  • Reduces duplicate code
  • Reusable across LWC/Aura

22. Enforcing CRUD & FLS Without Apex

What they asked me

โ€œHow do you enforce CRUD/FLS in LWC without writing Apex checks?โ€

What I said

UI API automatically applies:

  • Field-level security
  • Object CRUD
  • Record sharing rules

Example:

import { getRecordUi } from 'lightning/uiRecordApi';

UI API removes fields the user cannot see.

Tips

This is a MUST-mention in interviews.


23. Dynamic / Conditional CSS in LWC

What they asked me

โ€œHow did you highlight a row based on field value?โ€

What I said

I used getter functions to return CSS classes.

get rowClass() {
   return this.status === 'Active' ? 'green-background' : 'red-background';
}

Tips

Avoid directly manipulating DOM โ†’ use classes instead.


24. Using Slots to Build Reusable LWCs

What they asked me

โ€œHow did you make your modal generic and reusable?โ€

What I said

I used slots:

<div class="modal-body">
   <slot></slot>
</div>

Tips

Slots allow building flexible UI components โ†’ highly reusable.


25. Reusable Modal with @api Methods

What they asked me

โ€œHow do you show/hide modal from parent LWC?โ€

What I said

I created a reusable c-modal with public methods.

@api openModal() { this.show = true; }
@api closeModal() { this.show = false; }

Parent:

<c-modal lwc:ref="modal"></c-modal>
<lightning-button onclick={openModal}></lightning-button>

Tips

Modern and professional approach for reusable modals.


26. Dynamic Forms Generated from Metadata

What they asked me

โ€œHow did you build a form where fields changed based on picklist value?โ€

What I said

I used Metadata + UI API to build dynamic form:

fields = [
   { label: 'Name', type: 'text', value: this.name },
   { label: 'Age', type: 'number', value: this.age }
];

Rendered using loop:

<template for:each={fields} for:item="f">
    <lightning-input key={f.label} label={f.label} type={f.type}></lightning-input>
</template>

Tips

Shows advanced UI logic โ€” interviewers love this.


27. Bulk Updating Records in LWC

What they asked me

โ€œHow did you bulk update selected rows in a datatable?โ€

What I said

I collected selected rows then passed the array to Apex:

handleBulkSave() {
   updateInBulk({ records: this.selectedRows })
    .then(() => this.refresh());
}

Tips

  • Never loop DML in Apex
  • Use List<SObject>

28. Pre-Fill Fields in LWC Using getRecord

What they asked me

โ€œHow did you pre-populate form fields when editing?โ€

What I said

@wire(getRecord, { recordId: '$recordId', fields })
wiredRecord({ data }) {
    this.name = data.fields.Name.value;
}

Tips

UI API is faster than Apex for single record fetch.


29. Communication Between LWC & Aura

What they asked me

โ€œHow did you communicate between Aura component and LWC?โ€

What I said

Two ways:

LWC โ†’ Aura

Use CustomEvent

Aura โ†’ LWC

Use aura:id and @api methods.


30. Using LWC Inside a Flow (Screen Component)

What they asked me

โ€œHow did you pass data from Flow to LWC and back?โ€

What I said

I used Flow-supported decorators:

  • @api value
  • @api label
  • @api availableActions
  • @api invoke()

Output:

@api resultValue;

Tips

Mention: LWC is now preferred over Aura for Flow screens.


31. Reusable Pagination Component

What they asked me

โ€œHow did you build pagination that can be reused across pages?โ€

What I said

I built a separate LWC:

<c-pagination total={totalRecords} onnext={handleNext}></c-pagination>

Tips

Most enterprise apps need reusable pagination.


32. Lazy Loading on Tab Click

What they asked me

โ€œYou had multiple tabs in your UI. How did you load data only when needed?โ€

What I said

In tab change handler:

handleTabChange(event) {
   if (event.target.value === 'contacts') {
      this.loadContacts();
   }
}

Tips

This improves performance drastically.


33. When You Must Use Apex Instead of UI API

What they asked me

โ€œGive examples where UI API will not work.โ€

What I said

I used Apex when:

  • Need aggregate SOQL (SUM, GROUP BY)
  • Need complex joins
  • Need more than 2 object relations
  • Need more than 200 fields

Tips

Important to show that you choose Apex only when required.


34. Storing Temporary Values (Session Storage)

What they asked me

โ€œHow did you store unsaved form data?โ€

What I said

sessionStorage.setItem("draftAccount", JSON.stringify(this.form));

Tips

Helps in long multi-step forms.


35. Styling Child LWC from Parent (Shadow DOM Issue)

What they asked me

โ€œHow did you apply CSS to child LWC which is in Shadow DOM?โ€

What I said

I used:

  • CSS Custom Properties
  • or a shared static resource stylesheet

Example:

:host {
  --custom-color: red;
}

Child component uses:

color: var(--custom-color);

36. Record Permission Enforcement

What they asked me

โ€œHow did you disable edit buttons for users without access?โ€

What I said

Checked permissions via:

import { getRecordUi } from 'lightning/uiRecordApi';

This returns:

  • editable
  • updateable
  • readable

Tips

LWC + UI API = safest way to enforce security.


37. Search + Pagination Together

What they asked me

โ€œHow did you apply both search & pagination?โ€

What I said

Sent both to Apex:

searchText: this.searchKey,
pageNumber: this.page

Apex applies both:

WHERE Name LIKE :('%'+search+'%')
LIMIT 50 OFFSET :offset

38. Dynamic Icon Rendering Based on Value

What they asked me

โ€œHow did you conditionally render icons?โ€

What I said

get iconName() {
   return this.status === 'Active' ? 'utility:success' : 'utility:error';
}

39. Email Validation Using Regex

What they asked me

โ€œHow did you implement custom validation for email?โ€

What I said

const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

if (!regex.test(this.email)) {
   input.setCustomValidity("Invalid email format");
}

40. Preview PDF / Image in LWC

What they asked me

โ€œHow did you preview uploaded files?โ€

What I said

I used iframe:

<iframe src={filePreviewUrl}></iframe>

Preview URL:

'/sfc/servlet.shepherd/document/download/' + contentVersionId

41. Multi-Object Search in LWC

What they asked me

โ€œHow did you search multiple objects from a single search box?โ€

What I said

I created an Apex wrapper:

public class SearchWrapper {
   @AuraEnabled public List<Account> accounts;
   @AuraEnabled public List<Contact> contacts;
}

LWC displays grouped results.


42. Rendering Charts in LWC

What they asked me

โ€œHow did you show charts in LWC?โ€

What I said

Used Chart.js static resource.

Loaded like:

Promise.all([
   loadScript(this, chartJS)
])

43. Display Rich Text

What they asked me

โ€œHow did you show rich HTML or bold/colored text?โ€

What I said

<lightning-formatted-rich-text value={htmlContent}></lightning-formatted-rich-text>

44. renderedCallback() Real Use Case

What they asked me

โ€œWhen should you use renderedCallback?โ€

What I said

I used it for:

  • Loading external JS
  • Manipulating DOM once
  • Scroll positioning
renderedCallback() {
   if (this.loaded) return;
   this.loaded = true;
   this.initChart();
}

45. Infinite Scroll (Load More)

What they asked me

โ€œHow did you implement infinite scroll like mobile apps?โ€

What I said

I used scroll event โ†’ fetch next batch.


46. Notification Bell with Platform Events

What they asked me

โ€œHow did you build real-time notification bell?โ€

What I said

Subscribed to Platform Events โ†’ LWC updates UI.


47. Editable Modal with Dynamic Fields

What they asked me

โ€œHow did you create dynamic fields inside a modal?โ€

What I said

I generated inputs in a loop from metadata.


48. Fixing Re-Render Issues

What they asked me

โ€œYour component was re-rendering too often. What did you do?โ€

What I said

Reduced reactive properties & simplified template.


49. Reusable Layout Component

What they asked me

โ€œHow did you design a common layout?โ€

What I said

Created a wrapper LWC with slots.


50. Accessibility in LWC

What they asked me

โ€œHow do you ensure UI accessibility?โ€

What I said

I used:

  • ARIA labels
  • Keyboard navigation
  • Contrast rules

Example:

<button aria-label="Save Contact"></button>

๐Ÿ“š Bonus: Interview & Project Resources

๐Ÿ”ฅ Practice with real recruiter-level questions:
๐Ÿ‘‰ Salesforce Interview Mega-Pack โ€” 1000+ Real Questions & Answers

๐Ÿš€ Build end-to-end Salesforce Projects (with LWC + Trigger + Flow):
๐Ÿ‘‰ Sales Cloud Project for Developers โ€” Hands-On Implementation

TrailheadTitans

At TrailheadTitans.com, we are dedicated to paving the way for both freshers and experienced professionals in the dynamic world of Salesforce. Founded by Abhishek Kumar Singh, a seasoned professional with a rich background in various IT companies, our platform aims to be the go-to destination for job seekers seeking the latest opportunities and valuable resources.

Leave a Comment