🐧 ServerEffizienzsteigerung mit KI(16.09.2026 um 10:09 Uhr)
🐧 ServerPitch Deck erstellen: Anleitung mit und ohne KI(16.09.2026 um 11:09 Uhr)
🐧 Linux TippsSUPERHOT VR gets various upgrades ready for the Steam Frame(16.09.2026 um 10:17 Uhr)
🎥 Videosheise & c't: Deutschland im Rechenzentrum-Fieber(16.09.2026 um 10:00 Uhr)
🎥 Video | Youtubeheise & c't: Deutschland im Rechenzentrum-Fieber(16.09.2026 um 10:00 Uhr)
🐧 ServerEffizienzsteigerung mit KI(16.09.2026 um 10:09 Uhr)
🐧 ServerPitch Deck erstellen: Anleitung mit und ohne KI(16.09.2026 um 11:09 Uhr)
🐧 Linux TippsSUPERHOT VR gets various upgrades ready for the Steam Frame(16.09.2026 um 10:17 Uhr)
🎥 Videosheise & c't: Deutschland im Rechenzentrum-Fieber(16.09.2026 um 10:00 Uhr)
🎥 Video | Youtubeheise & c't: Deutschland im Rechenzentrum-Fieber(16.09.2026 um 10:00 Uhr)

🔧 Programmierung 🕛 vor 2 Jahren 6 Min Lesezeit
0

🚀 Day 5: Exploring List Rendering and Conditional Rendering in React🚀

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

Welcome to Day 5 of my React Learning Journey! Today, I delved into some fundamental concepts of React that are crucial for building dynamic and interactive applications: rendering lists and various techniques for conditional rendering. These concepts are essential for managing how components are displayed based on data and user interactions. Here’s what I learned:






Rendering Lists



In React, rendering lists involves iterating over an array of data and creating components for each item in the array. This is commonly done using the JavaScript map method. Here's an example using a list of pizza items:



Given below is the list of pizzas:




CODE
const pizzaData = [
{
name: "Focaccia",
ingredients: "Bread with Italian olive oil and rosemary",
price: 6,
photoName: "https://imgur.com/C3Ca4BS.png",
soldOut: false,
},
{
name: "Pizza Margherita",
ingredients: "Tomato and mozzarella",
price: 10,
photoName: "https://imgur.com/lipmW8F.png",
soldOut: false,
},
{
name: "Pizza Spinaci",
ingredients: "Tomato, mozzarella, spinach, and ricotta cheese",
price: 12,
photoName: "https://imgur.com/APdaPZR.png",
soldOut: false,
},
{
name: "Pizza Funghi",
ingredients: "Tomato, mozzarella, mushrooms, and onion",
price: 12,
photoName: "https://imgur.com/dPpvWzM.png",
soldOut: false,
},
{
name: "Pizza Salamino",
ingredients: "Tomato, mozzarella, and pepperoni",
price: 15,
photoName: "https://imgur.com/9dtZJNE.png",
soldOut: true,
},
{
name: "Pizza Prosciutto",
ingredients: "Tomato, mozzarella, ham, arugula, and burrata cheese",
price: 18,
photoName: "https://imgur.com/jii9M6S.png",
},
];






Pizza component is written as follows:




CODE
function Pizza({ pizzaObj }) {
return (
<li className="pizza">
<img src={pizzaObj.photoName} alt={pizzaObj.name} />
<div>
<h3>{pizzaObj.name}</h3>
<p>{pizzaObj.ingredients}</p>
<span>{pizzaObj.price}</span>
</div>
</li>
);
}






We can render list using map array function as:




CODE
<ul className="pizzas">
{pizzas.map((pizza) => (
<Pizza pizzaObj={pizza} key={pizza.name} />
))}
</ul>











Example: Menu Component






CODE
function Menu() {
const pizzas = [];

return (
<>
<h1>Our Menu</h1>

{pizzas.length > 0 && (
<ul className="pizzas">
{pizzas.map((pizza) => (
<Pizza pizzaObj={pizza} key={pizza.name} />
))}
</ul>
)}
</>
);
}






In this example, the list of pizzas is rendered only if there are items in the pizzas array.








Example: Footer Component






CODE
function Footer() {
const hour = new Date().getHours();
const openHour = 10;
const closeHour = 22;
const isOpen = hour >= openHour && hour <= closeHour;
console.log(isOpen);

return (
<footer className="footer">
{isOpen ? (
<p>
We're open from {openHour}:00 to {closeHour}:00. Come visit
us or order online.
</p>
) : (
<p>
We
're happy to welcome you between {openHour}:00 and{" "}
{closeHour}:00.
</p>
)}
</footer>
);
}






In this example, the ternary operator is used to render different messages depending on whether the restaurant is open.








Example: Pizza Component






CODE
function Pizza({ pizzaObj }) {
if (pizzaObj.soldOut) {
return null;
}

return (
<li className="pizza">
<img src={pizzaObj.photoName} alt={pizzaObj.name} />
<div>
<h3>{pizzaObj.name}</h3>
<p>{pizzaObj.ingredients}</p>
<span>{pizzaObj.price}</span>
</div>
</li>
);
}






for code samples and projects.

Connect with me on LinkedIn to stay updated on my latest projects and insights!

Vollständiger Original-Artikel
Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Oracle Patches 800+ Vulnerabilities in September 2026 Security Update
1 Quelle
Enterprises Warned of Attacks Exploiting WSO2 Vulnerability
1 Quelle
Prof. Kipker: Wir kommen dem KI-GAU näher
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten 🚀 Day 5: Exploring List Rendering and Conditional Rendering in React🚀

Thematisch verwandte Begriffe: Exploring, List, Rendering, Conditional · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...