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
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
PPTX
Conditional rendering
PPT
C++ basics
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
Conditional rendering
C++ basics

Similar to Conditional Rendering and rendering list in LWC (20)

PPT
Generalized Functors - Realizing Command Design Pattern in C++
PDF
Comprehensive JavaScript Cheat Sheet for Quick Reference and Mastery
PDF
JavaScript Cheatsheets with easy way .pdf
PPTX
Intro to RX
PDF
Letselectronic.blogspot.com robotic arm based on atmega mcu controlled by win...
PPTX
Web technologies-course 12.pptx
DOC
Workflow demo
PPT
Lecture 1
PPT
Lecture 1
PDF
Compose Camp - Session1.pdf
PDF
How to build a react native app with the help of react native hooks
PDF
Python master class 2
DOCX
Objectives Assignment 09 Applications of Stacks COS.docx
PDF
Angular 16 – the rise of Signals
ODP
Can't Dance The Lambda
PDF
How to start functional programming (in Scala): Day1
PDF
C interview questions
PDF
1669958779195.pdf
PPTX
Loops in java script
KEY
Architecting single-page front-end apps
Generalized Functors - Realizing Command Design Pattern in C++
Comprehensive JavaScript Cheat Sheet for Quick Reference and Mastery
JavaScript Cheatsheets with easy way .pdf
Intro to RX
Letselectronic.blogspot.com robotic arm based on atmega mcu controlled by win...
Web technologies-course 12.pptx
Workflow demo
Lecture 1
Lecture 1
Compose Camp - Session1.pdf
How to build a react native app with the help of react native hooks
Python master class 2
Objectives Assignment 09 Applications of Stacks COS.docx
Angular 16 – the rise of Signals
Can't Dance The Lambda
How to start functional programming (in Scala): Day1
C interview questions
1669958779195.pdf
Loops in java script
Architecting single-page front-end apps
Ad

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)

PPTX
Pharma ospi slides which help in ospi learning
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
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 Đ...
PPTX
Cell Structure & Organelles in detailed.
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PDF
English Language Teaching from Post-.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
PPTX
Introduction and Scope of Bichemistry.pptx
PDF
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Insiders guide to clinical Medicine.pdf
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Pharma ospi slides which help in ospi learning
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
O7-L3 Supply Chain Operations - ICLT Program
Abdominal Access Techniques with Prof. Dr. R K Mishra
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
NOI Hackathon - Summer Edition - GreenThumber.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Cell Structure & Organelles in detailed.
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
English Language Teaching from Post-.pdf
Renaissance Architecture: A Journey from Faith to Humanism
UPPER GASTRO INTESTINAL DISORDER.docx
Introduction and Scope of Bichemistry.pptx
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Insiders guide to clinical Medicine.pdf
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf

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