0% found this document useful (0 votes)
13 views

SFDC Interview Questiosn Part 2

LWC components replace Aura components and offer better performance, reusability, and productivity. Data binding connects component JavaScript and HTML, synchronizing property and UI updates. Components communicate via property binding, events, and publish-subscribe.

Uploaded by

spouledchild
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

SFDC Interview Questiosn Part 2

LWC components replace Aura components and offer better performance, reusability, and productivity. Data binding connects component JavaScript and HTML, synchronizing property and UI updates. Components communicate via property binding, events, and publish-subscribe.

Uploaded by

spouledchild
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Interviewer: How do LWC components differ from Aura components?

Interviewee: LWC components are the next generation of components in


the Salesforce ecosystem, replacing Aura components. LWC components offer better
performance, enhanced reusability, and improved development productivity
compared to Aura components.

Example Code : javascript

Example Code : javascript

1import { LightningElement } from 'lwc';


2
3export default class HelloWorld extends LightningElement {
4 greeting = 'Hello, Lightning Web Components!';
5}
Explanation: In the example code above, we have a simple LWC component that
defines a property called "greeting" and assigns it a value. This property can be
accessed and displayed in the component's template.

Interviewer: Explain the concept of data binding in LWC.

Interviewee: Data binding in LWC establishes a connection between the


component's JavaScript code and its HTML template. It enables dynamic updates
and synchronization of data between the component's properties and the UI.

Example Code :

Example Code :

html

1<template>
2 <lightning-card title="Data Binding Example">
3 <div class="slds-p-around_medium">
4 <h1>{greeting}</h1>

Pu
blic
5 </div>
6 </lightning-card>
7</template>
javascript

1import { LightningElement } from 'lwc';


2
3export default class HelloWorld extends LightningElement {
4 greeting = 'Hello, Lightning Web Components!';
5}
Explanation: In the example code above, we have a simple LWC component that
binds the "greeting" property to the <h1> tag in the template. Any changes to the
"greeting" property will automatically reflect in the UI.

Interviewer: How do you communicate between LWC components?

Interviewee: LWC provides various methods for component communication.


These include property binding for parent-child communication, events for child-
parent communication, and the publish-subscribe pattern for communication
between unrelated components.

Example Code : html

1<!-- Parent Component -->


2<template>
3 <c-child-component message="{parentMessage}"></c-child-component>
4</template>
javascript

1// Parent Component JS


2import { LightningElement } from 'lwc';
3
4export default class ParentComponent extends LightningElement {
5 parentMessage = 'Hello from Parent';
6
7 handleChildEvent(event) {
8 // Handle child event
9 const message = event.detail;
10 // Do something with the message
11 }
12}
html

1<!-- Child Component -->


2<template>

Pu
blic
3 <lightning-button label="Send Message" onclick="{handleClick}"></lightning-button>
4</template>
javascript

1// Child Component JS


2import { LightningElement, wire } from 'lwc';
3
4export default class ChildComponent extends LightningElement {
5 handleClick() {
6 const message = 'Hello from Child';
7 this.dispatchEvent(new CustomEvent('customevent', { detail: message }));
8 }
9}

Pu
blic

You might also like