Lightning Web Component and Lightning-Aura Component : Salesforce
Lightning Web Component and Lightning-Aura Component : Salesforce
Code Cheat Sheet for both Framework with Comparison
1. Component Bundles
Lightning-Aura Component
.comp : Markup or HTML
Controller.Js : Client Side Controller
Helper.Js : Client Side Util or Helper Controller
Render.Js : Client Side Render Controller
.css : CSS Resource for HTML
.auradoc : Aura Documentation
.design : Design Parameter for Builder
.SVG : SVG Resource for Component
Lightning Web Component
.html : Markup or HTML
Controller.Js : Client Side Controller
.css : CSS Resource for HTML
meta.xml : Design Parameter for Builder
2. JavaScript properties or Variables
Lightning-Aura Component
Lightning Web Component
import { LightningElement, api, track } from 'lwc';
export default class fetchRecords extends LightningElement {
@api recordId;
@track sobject;
}
3. Logical Operators
Lightning-Aura Component
//isLoading is a boolean variable in JS
3. Iterations
Lightning-Aura Component
//contactList is a List type attribute in Component
{!con.Name}
Lightning Web Component
{item}
4. Window Load or Document ready
Lightning-Aura Component
({
doInit : function(component, event) {
//any action as per requirement
}
})
Lightning Web Component
export default class fetchContact extends LightningElement {
connectedCallback() {
// initialize component
}
}
5. CSS File
Lightning-Aura Component
.THIS .header {
color: #FFFFFF;
background-color: #ccc;
padding: 10px;
}
Lightning Web Component
.header {
color: #FFFFFF;
background-color: #ccc;
padding: 10px;
}
6. Server Side Call
Lightning-Aura Component
var action = component.get("c.fetchRelatedContacts");
action.setCallback(this, function(data) {
var accountContacts=data.getReturnValue();
component.set("v.accountContacts", accountContacts);
});
$A.enqueueAction(action);
Lightning Web Component
import getAccountContacts from '@salesforce/apex/RelatedContactController.fetchAccountContacts';
export default class ApexImperativeMethod extends LightningElement {
@track accountContacts;
@track error;
connectedCallback() {
getAccountContacts({recordId: '$recordId'})
.then(result => {
this.accountContacts= result;
this.error = undefined;
})
.catch(error => {
this.error = error;
this.accountContacts = undefined;
});
}
}
7. Call Child Component
Lightning-Aura Component
//c:childComponent is another Lightning component
Lightning Web Component
//c-video-player is another LWC component
Lightning Web Component And Lightning-Aura Component : Salesforce >>>>> Download Now
ReplyDelete>>>>> Download Full
Lightning Web Component And Lightning-Aura Component : Salesforce >>>>> Download LINK
>>>>> Download Now
Lightning Web Component And Lightning-Aura Component : Salesforce >>>>> Download Full
>>>>> Download LINK XK