1. We extends LightningElement in LWC, What is the reason?
Ans: LightningElement is custom wrapper on HTMLElement which actually contains all the lifecycle hooks methods like connectedCallback(), disconnectedCallback(), renderedCallBack(). We can use this methods in LWC
2. What is the Lifecycle in LWC?
Ans:
a. Parent Constructor is called
b. Public property are set on parent
c, Parent is inserted to DOM
d. Once parent is inserted to DOM, Connected callback is called on parent
e. From this connected callback as parent is already inserted, you can reference different DOM elements.
f. Parent is rendered
g. Once parent is rendered, Constructor is called on the child
h. Public property of child are set
i. Child is inserted to DOM
j. Once child is inserted to DOM, Connected callback is called on child
k. Child is rendered
l. Once child is rendered, child rendered callback is called
m. Once child rendered callback is called, then parents rendered callback is called.
3. Is @wire method called multiple times during lifecycle of component in LWC ?
Ans:Yes, @wire method called multiple times in LWC
4. If we parent component X and there are two component Y and Z as child components. How can we communicate between Y and Z ?
Ans: We should fire up event from child component Y to parent X then from parent X call attribute / function exposed (as @api) and pass data into Z component.
5. Can we do DML in method annotated with @AuraEnabled(cacheable= true)?
Ans: No, we cannot do DML inside any method annotated with cacheable = true , we will receive an error as DMLLimit Exception.
6. Can we call function annotated with @AuraEnabled(cacheable= true) imperatively ?
Ans: Yes
7. How to refresh cache when calling method imperatively?
Ans: We have to use getRecordNotifyChange(RecordIds) which refreshes the Lightning Data Service cache providing you the latest data this will work only if cacheable = true was there. Otherwise we will have to call the function again from our js to get the latest data.
8. What happens when bubbles : false and composed : false (Default behavior)?
Ans:This is the default behavior, and bubbles and composed are not required to be defined explicitly.
When this is in effect, the event would not bubble up the DOM, as well as it would not cross shadow boundary.
We can listen these event only via defining the event handler to component that fires the event.
9. What happens when bubbles : true and composed : false ?
Ans: In this behavior, the event bubbles up the DOM, but don’t cross the shadow boundary. In simple terms, It bubbles up inside the current template, in which event is fired, but it would not cross it’s boundary.
For example :- There are two component, where parent component contain child component. If event is fired inside child component, the event only bubbles up inside child component, and it would not cross it’s boundary, and parent component will not be able to listen this event.
10. What does composed : true does in an event ?
Ans: These types of events can bubble up inside DOM and also able to cross shadow boundary.
For example :- There are two component, where parent component contain child component. If event is fired inside child component, the event bubbles up and it would cross it’s boundary, and parent component will be able to listen this event.
Subscribe blog for More updates !!!
Latest Salesforce Interview Questions and Answers:
Salesforce Interview Questions - Part 7
More Salesforce Blogs:
Difference Between Indirect Lookup and External Lookup In SalesforceWhat is the use of nextStartDate in Salesforce?
Check out Salesforce Daily Limit Only in 5 Simplest Steps
Learning Pagination In Salesforce Is Not Difficult At All ! You Just Need 3 Easy Steps
How To Learn Get Field Values From Visualforce Page To Apex Class Controller Without Losing Your Mind
Main Difference Between ISBLANK And ISNULL in Salesforce
How To Get Total Amount Of Records Processed In Batch Job In 10 Minutes And Still Look Your Best
Export VisualForce Data into Excel Sheet in 3 Easiest Steps
7 Easy Steps to Generate Apex Class From WSDL In Salesforce
Simplest Way To Find Number of Days Between Two Dates in Salesforce
3 Easy Steps To Send Emails With Attachment From Your Apex Class In Salesforce
How Insert Comma In Formula Fields Can Help You Improve Your Productivity
Simple Guidance For You In Access Of Subquery Field Value Using Apex - Upwards Traversal.
Access Subquery Field Value Using Apex in 2 Easy Steps- Downwards Traversal
How Learning Enable Inline Editing In Visual Force Pages Could Save Your Money And Time
No comments:
Post a Comment