SlideShare ist ein Scribd-Unternehmen logo
1 von 31
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 !!

Weitere ähnliche Inhalte

Was ist angesagt?

Lightning Web Component in Salesforce
Lightning Web Component in SalesforceLightning Web Component in Salesforce
Lightning Web Component in SalesforceJitendra Zaa
 
Lightning web components
Lightning web componentsLightning web components
Lightning web componentsAmit Chaudhary
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilitySalesforce Developers
 
Introduction to lightning components
Introduction to lightning componentsIntroduction to lightning components
Introduction to lightning componentsMohith Shrivastava
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce dataSalesforce Developers
 
Migrate To Lightning Web Components from Aura framework to increase performance
Migrate To Lightning Web Components from Aura framework to increase performance Migrate To Lightning Web Components from Aura framework to increase performance
Migrate To Lightning Web Components from Aura framework to increase performance Bohdan Dovhań
 
Salesforce Lightning Web Components Overview
Salesforce Lightning Web Components OverviewSalesforce Lightning Web Components Overview
Salesforce Lightning Web Components OverviewNagarjuna Kaipu
 
Lightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and Compositions
Lightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and CompositionsLightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and Compositions
Lightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and CompositionsNishant Singh Panwar
 
Lightning Web Components
Lightning Web ComponentsLightning Web Components
Lightning Web ComponentsAbdulGafoor100
 
Salesforce Tutorial for Beginners: Basic Salesforce Introduction
Salesforce Tutorial for Beginners: Basic Salesforce IntroductionSalesforce Tutorial for Beginners: Basic Salesforce Introduction
Salesforce Tutorial for Beginners: Basic Salesforce IntroductionHabilelabs
 
Salesforce integration best practices columbus meetup
Salesforce integration best practices   columbus meetupSalesforce integration best practices   columbus meetup
Salesforce integration best practices columbus meetupMuleSoft Meetup
 
Demystify Salesforce Bulk API
Demystify Salesforce Bulk APIDemystify Salesforce Bulk API
Demystify Salesforce Bulk APIDhanik Sahni
 
Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...
Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...
Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...Edureka!
 

Was ist angesagt? (20)

Lightning Web Component - LWC
Lightning Web Component - LWCLightning Web Component - LWC
Lightning Web Component - LWC
 
Lightning Web Component in Salesforce
Lightning Web Component in SalesforceLightning Web Component in Salesforce
Lightning Web Component in Salesforce
 
Lightning web components
Lightning web componentsLightning web components
Lightning web components
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
 
Introduction to lightning components
Introduction to lightning componentsIntroduction to lightning components
Introduction to lightning components
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
 
An Introduction to Lightning Web Components
An Introduction to Lightning Web ComponentsAn Introduction to Lightning Web Components
An Introduction to Lightning Web Components
 
Migrate To Lightning Web Components from Aura framework to increase performance
Migrate To Lightning Web Components from Aura framework to increase performance Migrate To Lightning Web Components from Aura framework to increase performance
Migrate To Lightning Web Components from Aura framework to increase performance
 
Salesforce Lightning Web Components Overview
Salesforce Lightning Web Components OverviewSalesforce Lightning Web Components Overview
Salesforce Lightning Web Components Overview
 
Lightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and Compositions
Lightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and CompositionsLightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and Compositions
Lightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and Compositions
 
Lightning Web Components
Lightning Web ComponentsLightning Web Components
Lightning Web Components
 
Live coding with LWC
Live coding with LWCLive coding with LWC
Live coding with LWC
 
Deep Dive into Apex Triggers
Deep Dive into Apex TriggersDeep Dive into Apex Triggers
Deep Dive into Apex Triggers
 
Salesforce Tutorial for Beginners: Basic Salesforce Introduction
Salesforce Tutorial for Beginners: Basic Salesforce IntroductionSalesforce Tutorial for Beginners: Basic Salesforce Introduction
Salesforce Tutorial for Beginners: Basic Salesforce Introduction
 
Exploring the Salesforce REST API
Exploring the Salesforce REST APIExploring the Salesforce REST API
Exploring the Salesforce REST API
 
Salesforce integration best practices columbus meetup
Salesforce integration best practices   columbus meetupSalesforce integration best practices   columbus meetup
Salesforce integration best practices columbus meetup
 
Demystify Salesforce Bulk API
Demystify Salesforce Bulk APIDemystify Salesforce Bulk API
Demystify Salesforce Bulk API
 
Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...
Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...
Salesforce Training For Beginners | Salesforce Tutorial | Salesforce Training...
 
SLDS and Lightning Components
SLDS and Lightning ComponentsSLDS and Lightning Components
SLDS and Lightning Components
 
Salesforce Lightning workshop
Salesforce Lightning workshopSalesforce Lightning workshop
Salesforce Lightning workshop
 

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

Implementing Vanilla Web Components
Implementing Vanilla Web ComponentsImplementing Vanilla Web Components
Implementing Vanilla Web Componentssonumanoj
 
Web Components v1
Web Components v1Web Components v1
Web Components v1Mike Wilcox
 
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friendWebcomponents are your frameworks best friend
Webcomponents are your frameworks best friendFilip 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 1Salesforce Developers
 
Winter '19 release development.ppt
Winter '19 release development.pptWinter '19 release development.ppt
Winter '19 release development.pptKailas Shimpi
 
Lightning Web Components by Abdul Gafoor
Lightning Web Components by Abdul GafoorLightning Web Components by Abdul Gafoor
Lightning Web Components by Abdul GafoorJayesh Tejwani
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDmitry 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 Benefitqrsolutionsindia
 
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
 
Introduction to lightning web component
Introduction to lightning web component Introduction to lightning web component
Introduction to lightning web component Sudipta Deb ☁
 
Web components
Web componentsWeb components
Web componentsMohd Saeed
 
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 arrivedGil Fink
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arpGary Pedretti
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introductioncherukumilli2
 
Lightning web components
Lightning web componentsLightning web components
Lightning web componentsAmit 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 2016Marco 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 EVERYWHERENadav Mary
 
Leveraging the Power of Custom Elements in Gutenberg
Leveraging the Power of Custom Elements in GutenbergLeveraging the Power of Custom Elements in Gutenberg
Leveraging the Power of Custom Elements in GutenbergFelix Arntz
 

Ähnlich wie Lightning web components - Introduction, component Lifecycle, Events, decorators and todo recipe (20)

Implementing Vanilla Web Components
Implementing Vanilla Web ComponentsImplementing Vanilla Web Components
Implementing Vanilla Web Components
 
Introduction to Lightning Web Components
Introduction to Lightning Web ComponentsIntroduction to Lightning Web Components
Introduction to Lightning Web Components
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
Webcomponents are your frameworks best friend
Webcomponents are your frameworks best friendWebcomponents are your frameworks best friend
Webcomponents are your frameworks best friend
 
Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1
 
Winter '19 release development.ppt
Winter '19 release development.pptWinter '19 release development.ppt
Winter '19 release development.ppt
 
Lightning Web Components by Abdul Gafoor
Lightning Web Components by Abdul GafoorLightning Web Components by Abdul Gafoor
Lightning Web Components by Abdul Gafoor
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
 
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]
 
Lightning Web Component Structure Benefit
Lightning Web Component Structure BenefitLightning Web Component Structure Benefit
Lightning Web Component Structure Benefit
 
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
 
Introduction to lightning web component
Introduction to lightning web component Introduction to lightning web component
Introduction to lightning web component
 
Web components
Web componentsWeb components
Web components
 
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
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
 
Lightning web components
Lightning web componentsLightning web components
Lightning web components
 
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
 
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
 
Leveraging the Power of Custom Elements in Gutenberg
Leveraging the Power of Custom Elements in GutenbergLeveraging the Power of Custom Elements in Gutenberg
Leveraging the Power of Custom Elements in Gutenberg
 

Kürzlich hochgeladen

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Kürzlich hochgeladen (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

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