SlideShare a Scribd company logo
6
Most read
14
Most read
17
Most read
Letterkenny, Ireland
Developers Group
Lk_Sf_Devs LkTrailblazers
Welcome to our virtual learning series
Learn Lightning Web Components in 5 Days
Day 2 - Recap + Decorators, Lifecycle hooks
and Compositions
Lightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and Compositions
Nishant Singh Panwar
Community Group Leader
Salesforce Developer and Consultant
● 6 Years of Salesforce Implementation Experience
● 8x Salesforce Certified - Application Architect
UDAIPUR
Nishant_SP
Actions
bit.ly/lwcquery
Sahil Batra (Director @ MTX Group Inc.)
Industry Experience
Having 9 year of experience in IT Industry and 6 years in Salesforce
ecosystem.Started my Salesforce career as Developer and have played
various roles like Technical Lead , Technical Architect and Corporate
Trainer.
Professional Highlights
● Manage Salesforce trainings and certifications.
● Work as Technical Architect / Principal Developer on Projects.
● Hold 5 Salesforce Certifications and 1 Google certification.
● Conducted Training in India, US , Australia and UK.
● Trained 500+ freshers and 300+ lateral folks in Salesforce.
● Trained 800+ students and 250+ faculty members.
Email : sahilbatraa@gmail.com
Twitter : sahilbatraa18
Topics covered in Session 1
● Introduction to LWC
● Why LWC ?
● 2014 Web stack
● 2019 Web Stack
● LWC Framework
● Aura & LWC
● Environment Setup
● LWC Bundle
● Build your First Component
● Applying CSS to Components
● Data Binding
● Conditional Rendering
● Loop & Iteration
Decorators : @track
Demo 3 & 6 : Reactive Private Properties
● Used with Private Property.
● Used if property is Object or an Array.
● All Primitive Type properties are reactive by Default.
● Data Types
○ Primitive Values - No @track Required
○ Objects - require @track
○ Arrays - require @track
Decorators : @api
Demo 7 : Public Properties
● Used with Public Property.
Decorators : @api
Demo 7 : Public Properties Mutation Demo
● Objects passed to components are read only.
● To trigger a mutation use events.
● Use primitive values for public properties
○ Define data shape and no complex documentation is required.
○ Standard HTML element only accept primitive values for attributes.
Public Boolean Properties
Demo 8 : Public Boolean Properties
● By Default value is false.
● Including a attribute value means passing true.
Use getter & setter to modify data
Demo 9 : getter setter properties
● Modify property value
● No need to declare a property
● If you write a setter for public property,you must also write a getter.
● Best practice is to annotate getter with @api. Do not annotate both.
Call Method on Child Component
Demo 10 : Public Methods
● To expose public method expose it with @api
● Parent component can call method to communicate down the hierarchy.
● querySelector() - return first element which matches selector
● querySelectorAll() - return an array of DOM elements.
● Do not use id as HTML template renders id may transformed into global unique
values
Using Slots
Demo 11 : Slots Demo
● Use to pass markup into components
● Similar to facets in Aura
● We have named and unnamed slots
● Do not include more than one unnamed slot
Component Lifecycle
Component
Requested
Constructor is
called
Update Public
Properties
Has public
properties?
Dom Inserted
Connected
Callback
DOM
Rendered
Has Child
Components?
Yes
Yes
Rendered
callback on
Child
Rendered
callback on
Parent
Parent
Removed from
DOM
disconnectedcallback
on Parent
Child removed
from DOM
disconnectedcallback
on Child
Component Lifecycle
● Constructor
○ Fires when component instance is created.
○ DOM manipulation cannot be done as DOM is not inserted yet.
○ Attribute assignment cannot be done.
○ Public properties are also not available
Component Lifecycle
● connectedCallback()
○ Fires when DOM is inserted.
○ You cannot access child elements as it flows from parent to child.
○ Fire more than once during lifecycle if we reorder component.
○ Mostly used for adding up event listeners.
○ DOM manipulation cannot be done as it is not rendered yet.
○ Attribute value assignment can be done here.
○ Flows from Parent to Child.
Component Lifecycle
● renderedCallback()
○ Called on child component first and than on to parent.
○ Use to perform logic after component has finished rendering phase.
○ Is called many times and we use some logic to execute only once.
○ Can create infinite loops.
○ Do not update public properties & tracked properties in renderedCallback()
Component Lifecycle
● disconnectedCallback()
○ Flows from Parent to child.
○ Called when component is removed from the DOM.
Demo 12 : Lifecycle Demo
Post your Queries @ bit.ly/lwcquery
Coming Up
● 14 May - Component communication using events.
bit.ly/lwcday3
● 21 May - Working with Salesforce data including LDS.
bit.ly/lwcday4
● 28 May - Navigation Services, Aura with LWC interoperability & extra topics.
bit.ly/lwcday5
RSVP
Lightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and Compositions

More Related Content

PPTX
Lightning web components - Introduction, component Lifecycle, Events, decorat...
PPTX
Best practices for implementing CI/CD on Salesforce
PPTX
Lightning Web Component - LWC
PDF
LWC Episode 3- Component Communication and Aura Interoperability
PPTX
Introduction to Lightning Web Component
PPTX
Lightning web components
PPTX
Angular Data Binding
PPTX
Lightning Web Components
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Best practices for implementing CI/CD on Salesforce
Lightning Web Component - LWC
LWC Episode 3- Component Communication and Aura Interoperability
Introduction to Lightning Web Component
Lightning web components
Angular Data Binding
Lightning Web Components

What's hot (20)

PPTX
Backstage at CNCF Madison.pptx
PDF
Lwc presentation
PPTX
Advanced angular
PDF
CI:CD in Lightspeed with kubernetes and argo cd
PPTX
Getting Started with Lightning Web Components | LWC | Salesforce
PDF
NGINX Ingress Controller for Kubernetes
PPTX
Introduction to lightning Web Component
PPTX
React + Redux Introduction
PDF
Introduction of Docker and Docker Compose
PPTX
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
PDF
Full Stack React Workshop [CSSC x GDSC]
ODP
Basics of VueJS
PPTX
.Net Core
PPTX
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
PPTX
Jenkins presentation
PPTX
react-slides.pptx
PDF
React Context API
PDF
Configuration management I - Ansible + Packer
PPTX
Lightning web components
PDF
Postman: An Introduction for API Ops Professionals
Backstage at CNCF Madison.pptx
Lwc presentation
Advanced angular
CI:CD in Lightspeed with kubernetes and argo cd
Getting Started with Lightning Web Components | LWC | Salesforce
NGINX Ingress Controller for Kubernetes
Introduction to lightning Web Component
React + Redux Introduction
Introduction of Docker and Docker Compose
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Full Stack React Workshop [CSSC x GDSC]
Basics of VueJS
.Net Core
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
Jenkins presentation
react-slides.pptx
React Context API
Configuration management I - Ansible + Packer
Lightning web components
Postman: An Introduction for API Ops Professionals
Ad

Similar to Lightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and Compositions (20)

PPTX
Salesforce Lightning Web Components Overview
PPTX
PDF
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
PDF
React js
PDF
Fundamental Concepts of React JS for Beginners.pdf
PDF
Full Stack Developer Course | Infinite Graphix Technologies
PPTX
React, Flux and more (p1)
PPTX
O365 Developer Bootcamp NJ 2018 - Material
PDF
React & Flux Workshop
PDF
react hook and wesite making structure ppt
PDF
React Interview Questions for Noobs or Juniors
PDF
Getting Started with React, When You’re an Angular Developer
PPTX
React Workshop: Core concepts of react
PPTX
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
PPTX
React workshop
PPTX
Salesforce lwc development workshops session #6
PPTX
React & Redux for noobs
PDF
theory-slides-vueh3urh4ur4ur4r44oirj4riu4ri
PDF
React - The JavaScript Library for User Interfaces
PDF
Welcome to React & Flux !
Salesforce Lightning Web Components Overview
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
React js
Fundamental Concepts of React JS for Beginners.pdf
Full Stack Developer Course | Infinite Graphix Technologies
React, Flux and more (p1)
O365 Developer Bootcamp NJ 2018 - Material
React & Flux Workshop
react hook and wesite making structure ppt
React Interview Questions for Noobs or Juniors
Getting Started with React, When You’re an Angular Developer
React Workshop: Core concepts of react
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React workshop
Salesforce lwc development workshops session #6
React & Redux for noobs
theory-slides-vueh3urh4ur4ur4r44oirj4riu4ri
React - The JavaScript Library for User Interfaces
Welcome to React & Flux !
Ad

More from Nishant Singh Panwar (12)

PDF
Admin Certification Sales and Service Cloud
PDF
Letterkenny TrailheaDX 2020 Global Gathering
PDF
Salesforce Admin Certification Preparation : Security Model Dive In
PDF
Lightning Web Components- Ep 2 - Component Communication using Events
PDF
Lightning Web Components- Ep 4 - Navigation Services, LWC and Aura Interopera...
PDF
Lightning Web Components- Ep 3 - Working with Salesforce data and LDS
PDF
Differential Salesforce DX - Virtual Dreamin
PDF
Lightning Web Components- Ep 0 - Introduction
PDF
Power of Flows and Prepare for Salesforce Admin Certification
PDF
Salesforce Spring 20 Highlights
PDF
Letterkenny Developer Group Meet - 28 Jan 2020
PPTX
Lkdug meet 17_dec19
Admin Certification Sales and Service Cloud
Letterkenny TrailheaDX 2020 Global Gathering
Salesforce Admin Certification Preparation : Security Model Dive In
Lightning Web Components- Ep 2 - Component Communication using Events
Lightning Web Components- Ep 4 - Navigation Services, LWC and Aura Interopera...
Lightning Web Components- Ep 3 - Working with Salesforce data and LDS
Differential Salesforce DX - Virtual Dreamin
Lightning Web Components- Ep 0 - Introduction
Power of Flows and Prepare for Salesforce Admin Certification
Salesforce Spring 20 Highlights
Letterkenny Developer Group Meet - 28 Jan 2020
Lkdug meet 17_dec19

Recently uploaded (20)

PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Getting started with AI Agents and Multi-Agent Systems
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
observCloud-Native Containerability and monitoring.pptx
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPT
Module 1.ppt Iot fundamentals and Architecture
PPT
What is a Computer? Input Devices /output devices
PPTX
The various Industrial Revolutions .pptx
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
Modernising the Digital Integration Hub
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Getting Started with Data Integration: FME Form 101
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Architecture types and enterprise applications.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Final SEM Unit 1 for mit wpu at pune .pptx
NewMind AI Weekly Chronicles - August'25-Week II
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Getting started with AI Agents and Multi-Agent Systems
OMC Textile Division Presentation 2021.pptx
cloud_computing_Infrastucture_as_cloud_p
observCloud-Native Containerability and monitoring.pptx
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Module 1.ppt Iot fundamentals and Architecture
What is a Computer? Input Devices /output devices
The various Industrial Revolutions .pptx
1. Introduction to Computer Programming.pptx
Chapter 5: Probability Theory and Statistics
Modernising the Digital Integration Hub
Zenith AI: Advanced Artificial Intelligence
Getting Started with Data Integration: FME Form 101
Web App vs Mobile App What Should You Build First.pdf
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Architecture types and enterprise applications.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

Lightning Web Components- Ep 1 - Decorators, Life Cycle Hooks and Compositions

  • 1. Letterkenny, Ireland Developers Group Lk_Sf_Devs LkTrailblazers Welcome to our virtual learning series Learn Lightning Web Components in 5 Days Day 2 - Recap + Decorators, Lifecycle hooks and Compositions
  • 3. Nishant Singh Panwar Community Group Leader Salesforce Developer and Consultant ● 6 Years of Salesforce Implementation Experience ● 8x Salesforce Certified - Application Architect UDAIPUR Nishant_SP
  • 5. Sahil Batra (Director @ MTX Group Inc.) Industry Experience Having 9 year of experience in IT Industry and 6 years in Salesforce ecosystem.Started my Salesforce career as Developer and have played various roles like Technical Lead , Technical Architect and Corporate Trainer. Professional Highlights ● Manage Salesforce trainings and certifications. ● Work as Technical Architect / Principal Developer on Projects. ● Hold 5 Salesforce Certifications and 1 Google certification. ● Conducted Training in India, US , Australia and UK. ● Trained 500+ freshers and 300+ lateral folks in Salesforce. ● Trained 800+ students and 250+ faculty members. Email : [email protected] Twitter : sahilbatraa18
  • 6. Topics covered in Session 1 ● Introduction to LWC ● Why LWC ? ● 2014 Web stack ● 2019 Web Stack ● LWC Framework ● Aura & LWC ● Environment Setup ● LWC Bundle ● Build your First Component ● Applying CSS to Components ● Data Binding ● Conditional Rendering ● Loop & Iteration
  • 7. Decorators : @track Demo 3 & 6 : Reactive Private Properties ● Used with Private Property. ● Used if property is Object or an Array. ● All Primitive Type properties are reactive by Default. ● Data Types ○ Primitive Values - No @track Required ○ Objects - require @track ○ Arrays - require @track
  • 8. Decorators : @api Demo 7 : Public Properties ● Used with Public Property.
  • 9. Decorators : @api Demo 7 : Public Properties Mutation Demo ● Objects passed to components are read only. ● To trigger a mutation use events. ● Use primitive values for public properties ○ Define data shape and no complex documentation is required. ○ Standard HTML element only accept primitive values for attributes.
  • 10. Public Boolean Properties Demo 8 : Public Boolean Properties ● By Default value is false. ● Including a attribute value means passing true.
  • 11. Use getter & setter to modify data Demo 9 : getter setter properties ● Modify property value ● No need to declare a property ● If you write a setter for public property,you must also write a getter. ● Best practice is to annotate getter with @api. Do not annotate both.
  • 12. Call Method on Child Component Demo 10 : Public Methods ● To expose public method expose it with @api ● Parent component can call method to communicate down the hierarchy. ● querySelector() - return first element which matches selector ● querySelectorAll() - return an array of DOM elements. ● Do not use id as HTML template renders id may transformed into global unique values
  • 13. Using Slots Demo 11 : Slots Demo ● Use to pass markup into components ● Similar to facets in Aura ● We have named and unnamed slots ● Do not include more than one unnamed slot
  • 14. Component Lifecycle Component Requested Constructor is called Update Public Properties Has public properties? Dom Inserted Connected Callback DOM Rendered Has Child Components? Yes Yes Rendered callback on Child Rendered callback on Parent Parent Removed from DOM disconnectedcallback on Parent Child removed from DOM disconnectedcallback on Child
  • 15. Component Lifecycle ● Constructor ○ Fires when component instance is created. ○ DOM manipulation cannot be done as DOM is not inserted yet. ○ Attribute assignment cannot be done. ○ Public properties are also not available
  • 16. Component Lifecycle ● connectedCallback() ○ Fires when DOM is inserted. ○ You cannot access child elements as it flows from parent to child. ○ Fire more than once during lifecycle if we reorder component. ○ Mostly used for adding up event listeners. ○ DOM manipulation cannot be done as it is not rendered yet. ○ Attribute value assignment can be done here. ○ Flows from Parent to Child.
  • 17. Component Lifecycle ● renderedCallback() ○ Called on child component first and than on to parent. ○ Use to perform logic after component has finished rendering phase. ○ Is called many times and we use some logic to execute only once. ○ Can create infinite loops. ○ Do not update public properties & tracked properties in renderedCallback()
  • 18. Component Lifecycle ● disconnectedCallback() ○ Flows from Parent to child. ○ Called when component is removed from the DOM. Demo 12 : Lifecycle Demo
  • 19. Post your Queries @ bit.ly/lwcquery
  • 20. Coming Up ● 14 May - Component communication using events. bit.ly/lwcday3 ● 21 May - Working with Salesforce data including LDS. bit.ly/lwcday4 ● 28 May - Navigation Services, Aura with LWC interoperability & extra topics. bit.ly/lwcday5 RSVP