SlideShare a Scribd company logo
Lightning Web
Components
Nidhi Sharma
Associate Tech Lead & Scrum Master
Metacube Software Pvt. Ltd.
Agenda
● What is Lightning Web Component?
● Journey of Web Stack and its evolution
● Fundamentals of Lightning Web Component
● Component LifeCycle Hooks
● Components Inter-Communication
● To-do-list recipe
What is Lightning Web Component?
Lightning Web Components are custom HTML elements built using HTML and
javascript.
Web Stack Journey
2014 Web Stack 2019 Web Stack
Lightning Web Components Stack
Fundamentals
HTML FILE
CSS FILE
CONFIGURATION
METADATA FILE
JAVASCRIPT
FILE
LIGHTNING
WEB
COMPONENT
Lightning Web Components Bundle
HTML TEMPLATE
The power of Lightning Web Components is the templating system, which uses the virtual DOM to render
components smartly and efficiently.
● A template is valid HTML with a <template> root tag.
● When a component renders, the <template> tag is replaced with the name of the component,
<namespace-component-name>
● Bind properties in a component’s template to properties in the component’s JavaScript class by
surrounding the property with curly braces, {property}
● Render DOM Elements Conditionally with if:true|false directive to a nested <template>
tag that encloses the conditional content.
HTML TEMPLATE
The power of Lightning Web Components is the templating system, which uses the virtual DOM to render
components smartly and efficiently.
<!-- helloConditionalRendering.html -->
<template>
<lightning-card title="HelloConditionalRendering" icon-name="custom:custom14">
<div class="slds-m-around_medium">
<lightning-input type="checkbox" label="Show details"
onchange={handleChange}></lightning-input>
<template if:true={areDetailsVisible}>
<div class="slds-m-vertical_medium">
These are the details!
</div>
</template>
</div>
</lightning-card>
</template>
Component CSS
● Components can’t share style sheets
● Each component can have only one style sheet
● Salesforce Lightning Design System is a CSS
framework
Decorators
@api
➔ Exposes public property.
➔ Owner component can access the
public properties
➔ Public properties are reactive
Decorators
@track
➔ Private reactive properties.
➔ Owner component cannot access
these properties
➔ Rerenders the content of the
component if the property changes.
Decorators
@wire
➔ Read data using wire adapters in
the lightning/ui*Api
➔ Owner component cannot access
these properties
➔ Rerenders the content of the
component if the property changes.
import getContactList from
'@salesforce/apex/ContactController.
getContactList';
@wire(getContactList)
wiredContacts
Component Lifecycle Hooks
Constructor()
Component Instance
Created
connectedCallback()
Component inserted in DOM
renderedCallBack()
Rendering is complete
render()
Component renders
disconnectedCallBack()
Component is removed
errorCallBack
(error, stack)
Captures error in hierarchy
Components
Communication
Flow Data in component Hierarchy
Parent
Child
@api child1
Child
@api child2
child-property=’Set me’
child-property =’Set me too’
● Child Components must declare Public API with
@api decorator
● Child Component can assign default value to the
public property but it cannot change the value of
the property.
● Only Parent can set the public property.
Flow Data in component Hierarchy
Parent
Child1
dispatchEvent
(child1Event)
Child2
dispatchEvent
(child2Event)
Child1Handler
Child2Handler
● Data must be passed up using Events.
● Events are created using the Event or
CustomEvent standard JavaScript classes
● Child components create and dispatch events.
● Parent component handles events dispatched by
child components.
Flow Data in component Hierarchy
lwc-brother
lwc-sister
● Use singleton library that follows the publish – subscribe pattern
● Salesforce has published such library - pubsub a service component that follows the
pattern
● This type of communication is also used for talking with Aura Components on the
same level.
aura-cousin
Lets cook LWC!!
Recipe - To-do-List
To-do-list
Task:
Desc
Priority
to-do-list
Add Item
to-do-form
to-do-app
Filter by Priority
To-do-List-Components
Task:
Desc
Priority
Add Item
to-do-app to-do-form
to-do-list
Filter by Priority
Ingredients (Tools)
● One - Salesforce CLI - installed
● One - Visual Studio Code - Installed
● One - Salesforce Extension package - Installed
● One - Development org - with enabled My Domain
in Org and DevHub
Seeking Help!!
● Lightning Component Library
● Playground
● TrailHead Sample Gallery
● Build Lightning Web Components
Trail
Preparation (Steps)
1. Create SFDX Project
a. Sfdx force:project:create --projectname toDoForm
b. Select SFDX:Create Project and provide name
1. Create Scratch Org
a. sfdx force:org:create -s -f config/project-scratch-def.json -a "wit"
b. Using VS Code - SFDX:Create a Default Scratch Org Project
1. Create Lightning Web Component
a. sfdx force:lightning:component:create --type lwc -n toDoForm -d force-
app/main/default/lwc
b. Using VS Code - Select SFDX:Create a Lightning Web Component
Project
to-do-form
Task:
Desc
Priority
Add Item
to-do-form
toDoForm
toDoForm.html
toDoForm.js
toDoForm.js-meta.xml
Lets cook (coding time )!!
Task:
Desc
Priority
Add Item
to-do-form
Serving steps
Drag toDoApp Component on the page you want to see your component
To-do-app Recipe is Ready to Serve!!
Q & A
Thank You !!

More Related Content

What's hot (20)

PPTX
Intro to Salesforce Lightning Web Components (LWC)
Roy Gilad
 
PPTX
Lightning Web Component in Salesforce
Jitendra Zaa
 
PPTX
Introduction to Lightning Web Component
SmritiSharan1
 
PPTX
Lightning web components
Amit Chaudhary
 
PPTX
Introduction to lightning components
Mohith Shrivastava
 
PDF
Best Practices with Apex in 2022.pdf
Mohith Shrivastava
 
PPTX
Salesforce Lightning Web Components Overview
Nagarjuna Kaipu
 
PPTX
Lightning Web Components
AbdulGafoor100
 
PPTX
Lightning web component
Dhanik Sahni
 
PPTX
An Introduction to Lightning Web Components
Mikkel Flindt Heisterberg
 
PPTX
Real Time Integration with Salesforce Platform Events
Salesforce Developers
 
PDF
Live coding with LWC
Salesforce Developers
 
PPTX
Java Spring
AathikaJava
 
PPTX
Episode 20 - Trigger Frameworks in Salesforce
Jitendra Zaa
 
PDF
Decluttering your Salesfroce org
Roy Gilad
 
PDF
Performing a successful technical debt assessment in Salesforce
Coforge (Erstwhile WHISHWORKS)
 
PPTX
Salesforce Development Best Practices
Vivek Chawla
 
PPT
Spring Boot in Action
Alex Movila
 
PPTX
Angular Data Binding
Jennifer Estrada
 
PPTX
Getting Started with Lightning Web Components | LWC | Salesforce
Rahul Malhotra
 
Intro to Salesforce Lightning Web Components (LWC)
Roy Gilad
 
Lightning Web Component in Salesforce
Jitendra Zaa
 
Introduction to Lightning Web Component
SmritiSharan1
 
Lightning web components
Amit Chaudhary
 
Introduction to lightning components
Mohith Shrivastava
 
Best Practices with Apex in 2022.pdf
Mohith Shrivastava
 
Salesforce Lightning Web Components Overview
Nagarjuna Kaipu
 
Lightning Web Components
AbdulGafoor100
 
Lightning web component
Dhanik Sahni
 
An Introduction to Lightning Web Components
Mikkel Flindt Heisterberg
 
Real Time Integration with Salesforce Platform Events
Salesforce Developers
 
Live coding with LWC
Salesforce Developers
 
Java Spring
AathikaJava
 
Episode 20 - Trigger Frameworks in Salesforce
Jitendra Zaa
 
Decluttering your Salesfroce org
Roy Gilad
 
Performing a successful technical debt assessment in Salesforce
Coforge (Erstwhile WHISHWORKS)
 
Salesforce Development Best Practices
Vivek Chawla
 
Spring Boot in Action
Alex Movila
 
Angular Data Binding
Jennifer Estrada
 
Getting Started with Lightning Web Components | LWC | Salesforce
Rahul Malhotra
 

Similar to Lightning web components - Introduction, component Lifecycle, Events, decorators and todo recipe (20)

PPTX
Lightning Web Component - LWC
Thierry TROUIN ☁
 
PDF
Lightning Web Component Structure Benefit
qrsolutionsindia
 
PDF
What is Difference Between LC and LWC?
Ravendra Singh
 
PPTX
Introduction to lightning web component
Sudipta Deb ☁
 
PDF
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Ben Edwards
 
PPTX
Lightning Web Components by Abdul Gafoor
Jayesh Tejwani
 
PPT
Migrate To Lightning Web Components from Aura framework to increase performance
Bohdan Dovhań
 
PDF
Introduction to Lightning Web Components
Bordeaux Salesforce Developer Group
 
PPTX
RVA intro to LWC- Salesforce Dev Week
Ohad Idan
 
PDF
Lightning Components Explained
Atul Gupta(8X)
 
PPTX
Implementing Vanilla Web Components
sonumanoj
 
PPTX
Boston, MA Developer Group 2/7/2019 - Introduction to lightning web components
BingWang77
 
PDF
Lightning Web Components - A new era, René Winkelmeyer
CzechDreamin
 
PPTX
Lightning web components
Amit Chaudhary
 
PPTX
SFDC Lightning Demo
Samar Saha
 
PDF
Intro to lwc - dev week slides
Sara Sali
 
PDF
Deep diving into building lightning components
Cloud Analogy
 
PPTX
Intro to Lightning Web Components
Calvin LaBelle
 
PPTX
LWC_Workbxcgbgfbgfbfgbfgbfbfbshop_Day2.pptx
Vkrish Peru
 
PPTX
A Review on LWC Events for communication.pptx
KadharBashaJ
 
Lightning Web Component - LWC
Thierry TROUIN ☁
 
Lightning Web Component Structure Benefit
qrsolutionsindia
 
What is Difference Between LC and LWC?
Ravendra Singh
 
Introduction to lightning web component
Sudipta Deb ☁
 
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Ben Edwards
 
Lightning Web Components by Abdul Gafoor
Jayesh Tejwani
 
Migrate To Lightning Web Components from Aura framework to increase performance
Bohdan Dovhań
 
Introduction to Lightning Web Components
Bordeaux Salesforce Developer Group
 
RVA intro to LWC- Salesforce Dev Week
Ohad Idan
 
Lightning Components Explained
Atul Gupta(8X)
 
Implementing Vanilla Web Components
sonumanoj
 
Boston, MA Developer Group 2/7/2019 - Introduction to lightning web components
BingWang77
 
Lightning Web Components - A new era, René Winkelmeyer
CzechDreamin
 
Lightning web components
Amit Chaudhary
 
SFDC Lightning Demo
Samar Saha
 
Intro to lwc - dev week slides
Sara Sali
 
Deep diving into building lightning components
Cloud Analogy
 
Intro to Lightning Web Components
Calvin LaBelle
 
LWC_Workbxcgbgfbgfbfgbfgbfbfbshop_Day2.pptx
Vkrish Peru
 
A Review on LWC Events for communication.pptx
KadharBashaJ
 
Ad

Recently uploaded (20)

PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Ad

Lightning web components - Introduction, component Lifecycle, Events, decorators and todo recipe

  • 1. Lightning Web Components Nidhi Sharma Associate Tech Lead & Scrum Master Metacube Software Pvt. Ltd.
  • 2. Agenda ● What is Lightning Web Component? ● Journey of Web Stack and its evolution ● Fundamentals of Lightning Web Component ● Component LifeCycle Hooks ● Components Inter-Communication ● To-do-list recipe
  • 3. What is Lightning Web Component? Lightning Web Components are custom HTML elements built using HTML and javascript.
  • 5. 2014 Web Stack 2019 Web Stack
  • 8. HTML FILE CSS FILE CONFIGURATION METADATA FILE JAVASCRIPT FILE LIGHTNING WEB COMPONENT Lightning Web Components Bundle
  • 9. HTML TEMPLATE The power of Lightning Web Components is the templating system, which uses the virtual DOM to render components smartly and efficiently. ● A template is valid HTML with a <template> root tag. ● When a component renders, the <template> tag is replaced with the name of the component, <namespace-component-name> ● Bind properties in a component’s template to properties in the component’s JavaScript class by surrounding the property with curly braces, {property} ● Render DOM Elements Conditionally with if:true|false directive to a nested <template> tag that encloses the conditional content.
  • 10. HTML TEMPLATE The power of Lightning Web Components is the templating system, which uses the virtual DOM to render components smartly and efficiently. <!-- helloConditionalRendering.html --> <template> <lightning-card title="HelloConditionalRendering" icon-name="custom:custom14"> <div class="slds-m-around_medium"> <lightning-input type="checkbox" label="Show details" onchange={handleChange}></lightning-input> <template if:true={areDetailsVisible}> <div class="slds-m-vertical_medium"> These are the details! </div> </template> </div> </lightning-card> </template>
  • 11. Component CSS ● Components can’t share style sheets ● Each component can have only one style sheet ● Salesforce Lightning Design System is a CSS framework
  • 12. Decorators @api ➔ Exposes public property. ➔ Owner component can access the public properties ➔ Public properties are reactive
  • 13. Decorators @track ➔ Private reactive properties. ➔ Owner component cannot access these properties ➔ Rerenders the content of the component if the property changes.
  • 14. Decorators @wire ➔ Read data using wire adapters in the lightning/ui*Api ➔ Owner component cannot access these properties ➔ Rerenders the content of the component if the property changes. import getContactList from '@salesforce/apex/ContactController. getContactList'; @wire(getContactList) wiredContacts
  • 15. Component Lifecycle Hooks Constructor() Component Instance Created connectedCallback() Component inserted in DOM renderedCallBack() Rendering is complete render() Component renders disconnectedCallBack() Component is removed errorCallBack (error, stack) Captures error in hierarchy
  • 17. Flow Data in component Hierarchy Parent Child @api child1 Child @api child2 child-property=’Set me’ child-property =’Set me too’ ● Child Components must declare Public API with @api decorator ● Child Component can assign default value to the public property but it cannot change the value of the property. ● Only Parent can set the public property.
  • 18. Flow Data in component Hierarchy Parent Child1 dispatchEvent (child1Event) Child2 dispatchEvent (child2Event) Child1Handler Child2Handler ● Data must be passed up using Events. ● Events are created using the Event or CustomEvent standard JavaScript classes ● Child components create and dispatch events. ● Parent component handles events dispatched by child components.
  • 19. Flow Data in component Hierarchy lwc-brother lwc-sister ● Use singleton library that follows the publish – subscribe pattern ● Salesforce has published such library - pubsub a service component that follows the pattern ● This type of communication is also used for talking with Aura Components on the same level. aura-cousin
  • 20. Lets cook LWC!! Recipe - To-do-List
  • 23. Ingredients (Tools) ● One - Salesforce CLI - installed ● One - Visual Studio Code - Installed ● One - Salesforce Extension package - Installed ● One - Development org - with enabled My Domain in Org and DevHub
  • 24. Seeking Help!! ● Lightning Component Library ● Playground ● TrailHead Sample Gallery ● Build Lightning Web Components Trail
  • 25. Preparation (Steps) 1. Create SFDX Project a. Sfdx force:project:create --projectname toDoForm b. Select SFDX:Create Project and provide name 1. Create Scratch Org a. sfdx force:org:create -s -f config/project-scratch-def.json -a "wit" b. Using VS Code - SFDX:Create a Default Scratch Org Project 1. Create Lightning Web Component a. sfdx force:lightning:component:create --type lwc -n toDoForm -d force- app/main/default/lwc b. Using VS Code - Select SFDX:Create a Lightning Web Component Project
  • 27. Lets cook (coding time )!! Task: Desc Priority Add Item to-do-form
  • 28. Serving steps Drag toDoApp Component on the page you want to see your component
  • 29. To-do-app Recipe is Ready to Serve!!
  • 30. Q & A