SlideShare a Scribd company logo
Conditional Rendering and rendering list in LWC
Conditional Rendering and rendering list in LWC
Conditional Rendering and rendering list in LWC
Agenda
 What is Conditional Rendering
 Understanding code line by line
What is Conditional Rendering?
 If you want to hide some of the components from the HTML and show it based on
conditions then use conditional rendering.
How to achieve conditional rendering in
LWC?
 Like Aura Components <Aura:if>, apex (if, else) the same way we have <template
if:true> and <template if:false>in Lightning web component.
Conditional Rendering Example
1. Design the component
2. On the basis of checkbox element should appear
Conditional Rendering Example 2
1. Design the component
2. On the click of button element should appear
Homework
Conditional Rendering and rendering list in LWC
Agenda
 What is loop
 for:each and iterator directives
 Advantage of iterator
 Understanding code line by line
What is Loop
 Loops allow you to do a task over and over again.
1
2
3
4
5
6
//Sample for loop code in apex
List <String> fit = new List<String>{'Gym', 'Crossfit', 'Yoga'};
for(String f : fit){
System.debug('We have ' + f);
}
Iterate over multiple items in LWC
 for:each
 Iterator
 Key
 Whenever we use for:each or Iterator we need to use key directive on the element on
which we are doing iteration. Key gives unique id to each item
For:each Example
Iterator
 Properties of Iterator:
 value: items in the list
 index: index of item in the list
 first: Boolean indicating first item in the collection
 last: Boolean indicating last item in the collection
Iterator Example
Homework
Conditional Rendering and rendering list in LWC
Calculator
Q&A
Q&A
Thank you

More Related Content

PPTX
Conditional rendering
PPTX
Javascripts hidden treasures BY - https://geekyants.com/
PPTX
Nairobi JVM meetup : Introduction to akka
 
PDF
Introduction to Higher Order Functions in Scala
PPTX
Interface and abstraction
DOCX
Static keyword a.z
PPT
C++ basics
Conditional rendering
Javascripts hidden treasures BY - https://geekyants.com/
Nairobi JVM meetup : Introduction to akka
 
Introduction to Higher Order Functions in Scala
Interface and abstraction
Static keyword a.z
C++ basics

More from SmritiSharan1 (8)

PPTX
Styling and Data Binding in Lightning Web Component
PPTX
Live session 2 lightning web component
PPTX
Live Session1 lightning web component
PPTX
Salesforce DX for Scratch Orgs
PPTX
Chapter 3 : Setup SalesforceDX (SFDX) for Non Scratch Orgs
PPTX
Introduction to Lightning Web Component
PPTX
Session 1: INTRODUCTION TO SALESFORCE
PPTX
Introduction to lightning lifecycle
Styling and Data Binding in Lightning Web Component
Live session 2 lightning web component
Live Session1 lightning web component
Salesforce DX for Scratch Orgs
Chapter 3 : Setup SalesforceDX (SFDX) for Non Scratch Orgs
Introduction to Lightning Web Component
Session 1: INTRODUCTION TO SALESFORCE
Introduction to lightning lifecycle
Ad

Recently uploaded (20)

PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Insiders guide to clinical Medicine.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Pharma ospi slides which help in ospi learning
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Pre independence Education in Inndia.pdf
PPTX
Cell Types and Its function , kingdom of life
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Microbial disease of the cardiovascular and lymphatic systems
Renaissance Architecture: A Journey from Faith to Humanism
Insiders guide to clinical Medicine.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Abdominal Access Techniques with Prof. Dr. R K Mishra
TR - Agricultural Crops Production NC III.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Pharma ospi slides which help in ospi learning
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Pre independence Education in Inndia.pdf
Cell Types and Its function , kingdom of life
human mycosis Human fungal infections are called human mycosis..pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Microbial diseases, their pathogenesis and prophylaxis
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Anesthesia in Laparoscopic Surgery in India
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
VCE English Exam - Section C Student Revision Booklet
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Ad

Conditional Rendering and rendering list in LWC

  • 4. Agenda  What is Conditional Rendering  Understanding code line by line
  • 5. What is Conditional Rendering?  If you want to hide some of the components from the HTML and show it based on conditions then use conditional rendering.
  • 6. How to achieve conditional rendering in LWC?  Like Aura Components <Aura:if>, apex (if, else) the same way we have <template if:true> and <template if:false>in Lightning web component.
  • 7. Conditional Rendering Example 1. Design the component 2. On the basis of checkbox element should appear
  • 8. Conditional Rendering Example 2 1. Design the component 2. On the click of button element should appear
  • 11. Agenda  What is loop  for:each and iterator directives  Advantage of iterator  Understanding code line by line
  • 12. What is Loop  Loops allow you to do a task over and over again. 1 2 3 4 5 6 //Sample for loop code in apex List <String> fit = new List<String>{'Gym', 'Crossfit', 'Yoga'}; for(String f : fit){ System.debug('We have ' + f); }
  • 13. Iterate over multiple items in LWC  for:each  Iterator  Key  Whenever we use for:each or Iterator we need to use key directive on the element on which we are doing iteration. Key gives unique id to each item
  • 15. Iterator  Properties of Iterator:  value: items in the list  index: index of item in the list  first: Boolean indicating first item in the collection  last: Boolean indicating last item in the collection
  • 20. Q&A
  • 21. Q&A