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 !!
Ad

More Related Content

What's hot (20)

Lightning web components
Lightning web componentsLightning web components
Lightning web components
Amit Chaudhary
 
Lwc presentation
Lwc presentationLwc presentation
Lwc presentation
Nithesh N
 
Introduction to Lightning Web Component
Introduction to Lightning Web Component Introduction to Lightning Web Component
Introduction to Lightning Web Component
SmritiSharan1
 
Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)
Roy Gilad
 
Lightning Web Components
Lightning Web ComponentsLightning Web Components
Lightning Web Components
AbdulGafoor100
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
Salesforce Developers
 
Getting Started with Lightning Web Components | LWC | Salesforce
Getting Started with Lightning Web Components | LWC | SalesforceGetting Started with Lightning Web Components | LWC | Salesforce
Getting Started with Lightning Web Components | LWC | Salesforce
Rahul Malhotra
 
Lightning Web Component - LWC
Lightning Web Component - LWCLightning Web Component - LWC
Lightning Web Component - LWC
Thierry TROUIN ☁
 
Lightning web component
Lightning web componentLightning web component
Lightning web component
Dhanik Sahni
 
Lightning Web Component in Salesforce
Lightning Web Component in SalesforceLightning Web Component in Salesforce
Lightning Web Component in Salesforce
Jitendra Zaa
 
Getting Started With Apex REST Services
Getting Started With Apex REST ServicesGetting Started With Apex REST Services
Getting Started With Apex REST Services
Salesforce Developers
 
Lightning Components Introduction
Lightning Components IntroductionLightning Components Introduction
Lightning Components Introduction
Durgesh Dhoot
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
Eyal Vardi
 
Salesforce Lightning Process builder
Salesforce Lightning Process builderSalesforce Lightning Process builder
Salesforce Lightning Process builder
Thinqloud
 
Dynamic input tables lwc vs aura vs. visualforce
Dynamic input tables  lwc vs aura vs. visualforceDynamic input tables  lwc vs aura vs. visualforce
Dynamic input tables lwc vs aura vs. visualforce
Mike Tetlow
 
Angular 2
Angular 2Angular 2
Angular 2
Nigam Goyal
 
An Introduction to Lightning Web Components
An Introduction to Lightning Web ComponentsAn Introduction to Lightning Web Components
An Introduction to Lightning Web Components
Mikkel Flindt Heisterberg
 
Introduction to lightning web component
Introduction to lightning web component Introduction to lightning web component
Introduction to lightning web component
Sudipta Deb ☁
 
Lightning Component - Components, Actions and Events
Lightning Component - Components, Actions and EventsLightning Component - Components, Actions and Events
Lightning Component - Components, Actions and Events
Durgesh Dhoot
 
Intro to React
Intro to ReactIntro to React
Intro to React
Justin Reock
 
Lightning web components
Lightning web componentsLightning web components
Lightning web components
Amit Chaudhary
 
Lwc presentation
Lwc presentationLwc presentation
Lwc presentation
Nithesh N
 
Introduction to Lightning Web Component
Introduction to Lightning Web Component Introduction to Lightning Web Component
Introduction to Lightning Web Component
SmritiSharan1
 
Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)Intro to Salesforce Lightning Web Components (LWC)
Intro to Salesforce Lightning Web Components (LWC)
Roy Gilad
 
Lightning Web Components
Lightning Web ComponentsLightning Web Components
Lightning Web Components
AbdulGafoor100
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
Salesforce Developers
 
Getting Started with Lightning Web Components | LWC | Salesforce
Getting Started with Lightning Web Components | LWC | SalesforceGetting Started with Lightning Web Components | LWC | Salesforce
Getting Started with Lightning Web Components | LWC | Salesforce
Rahul Malhotra
 
Lightning web component
Lightning web componentLightning web component
Lightning web component
Dhanik Sahni
 
Lightning Web Component in Salesforce
Lightning Web Component in SalesforceLightning Web Component in Salesforce
Lightning Web Component in Salesforce
Jitendra Zaa
 
Getting Started With Apex REST Services
Getting Started With Apex REST ServicesGetting Started With Apex REST Services
Getting Started With Apex REST Services
Salesforce Developers
 
Lightning Components Introduction
Lightning Components IntroductionLightning Components Introduction
Lightning Components Introduction
Durgesh Dhoot
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
Eyal Vardi
 
Salesforce Lightning Process builder
Salesforce Lightning Process builderSalesforce Lightning Process builder
Salesforce Lightning Process builder
Thinqloud
 
Dynamic input tables lwc vs aura vs. visualforce
Dynamic input tables  lwc vs aura vs. visualforceDynamic input tables  lwc vs aura vs. visualforce
Dynamic input tables lwc vs aura vs. visualforce
Mike Tetlow
 
Introduction to lightning web component
Introduction to lightning web component Introduction to lightning web component
Introduction to lightning web component
Sudipta Deb ☁
 
Lightning Component - Components, Actions and Events
Lightning Component - Components, Actions and EventsLightning Component - Components, Actions and Events
Lightning Component - Components, Actions and Events
Durgesh Dhoot
 

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

Salesforce Lightning Web Components Overview
Salesforce Lightning Web Components OverviewSalesforce Lightning Web Components Overview
Salesforce Lightning Web Components Overview
Nagarjuna Kaipu
 
Implementing Vanilla Web Components
Implementing Vanilla Web ComponentsImplementing Vanilla Web Components
Implementing Vanilla Web Components
sonumanoj
 
Introduction to Lightning Web Components
Introduction to Lightning Web ComponentsIntroduction to Lightning Web Components
Introduction to Lightning Web Components
Bordeaux Salesforce Developer Group
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
Mike Wilcox
 
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friendWebcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1
Salesforce Developers
 
Winter '19 release development.ppt
Winter '19 release development.pptWinter '19 release development.ppt
Winter '19 release development.ppt
Kailas Shimpi
 
Lightning Web Components by Abdul Gafoor
Lightning Web Components by Abdul GafoorLightning Web Components by Abdul Gafoor
Lightning Web Components by Abdul Gafoor
Jayesh Tejwani
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
Dmitry Vinnik
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Lightning Web Component Structure Benefit
Lightning Web Component Structure BenefitLightning Web Component Structure Benefit
Lightning Web Component Structure Benefit
qrsolutionsindia
 
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Ben Edwards
 
Web components
Web componentsWeb components
Web components
Mohd Saeed
 
Full Stack_Reac web Development and Application
Full Stack_Reac web Development and ApplicationFull Stack_Reac web Development and Application
Full Stack_Reac web Development and Application
Jeyarajs7
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
Gil Fink
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
Gary Pedretti
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
cherukumilli2
 
Lightning web components
Lightning web componentsLightning web components
Lightning web components
Amit Chaudhary
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
Marco Breveglieri
 
Angular elements - embed your angular components EVERYWHERE
Angular elements - embed your angular components EVERYWHEREAngular elements - embed your angular components EVERYWHERE
Angular elements - embed your angular components EVERYWHERE
Nadav Mary
 
Salesforce Lightning Web Components Overview
Salesforce Lightning Web Components OverviewSalesforce Lightning Web Components Overview
Salesforce Lightning Web Components Overview
Nagarjuna Kaipu
 
Implementing Vanilla Web Components
Implementing Vanilla Web ComponentsImplementing Vanilla Web Components
Implementing Vanilla Web Components
sonumanoj
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
Mike Wilcox
 
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friendWebcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1
Salesforce Developers
 
Winter '19 release development.ppt
Winter '19 release development.pptWinter '19 release development.ppt
Winter '19 release development.ppt
Kailas Shimpi
 
Lightning Web Components by Abdul Gafoor
Lightning Web Components by Abdul GafoorLightning Web Components by Abdul Gafoor
Lightning Web Components by Abdul Gafoor
Jayesh Tejwani
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
Dmitry Vinnik
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Lightning Web Component Structure Benefit
Lightning Web Component Structure BenefitLightning Web Component Structure Benefit
Lightning Web Component Structure Benefit
qrsolutionsindia
 
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Ben Edwards
 
Web components
Web componentsWeb components
Web components
Mohd Saeed
 
Full Stack_Reac web Development and Application
Full Stack_Reac web Development and ApplicationFull Stack_Reac web Development and Application
Full Stack_Reac web Development and Application
Jeyarajs7
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
Gil Fink
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
Gary Pedretti
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
cherukumilli2
 
Lightning web components
Lightning web componentsLightning web components
Lightning web components
Amit Chaudhary
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
Marco Breveglieri
 
Angular elements - embed your angular components EVERYWHERE
Angular elements - embed your angular components EVERYWHEREAngular elements - embed your angular components EVERYWHERE
Angular elements - embed your angular components EVERYWHERE
Nadav Mary
 
Ad

Recently uploaded (20)

Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Learn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step GuideLearn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step Guide
Marcel David
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Salesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docxSalesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docx
José Enrique López Rivera
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Learn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step GuideLearn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step Guide
Marcel David
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Salesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docxSalesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docx
José Enrique López Rivera
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
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