- Forums
- ionic
- ARRAY map() in React - How To Use Ionic Map In ARRAY With React
ARRAY map() Usage for React - How To Use Ionic Map In ARRAY With React [5015], Last Updated: Mon Jun 24, 2024
me
Sun Sep 11, 2022
0 Comments
661 Visits
// make your imports here, useState not required just using as example
import { useState } from "react";
const labels = ["Family", "Friends", "Notes", "Work", "Travel", "Reminders"];
const Menu: React.FC = () => {
return (
// loop through the array
<IonList id="labels-list">
<IonListHeader>Labels</IonListHeader>
{labels.map((label, index) => (
<IonItem lines="none" key={index}>
<IonIcon slot="start" icon={bookmarkOutline} />
<IonLabel>{label}</IonLabel>
</IonItem>
))}
</IonList>
);
};
export default Menu;