react beginner here after not being able to find any helpful leads while googling.
Given a list of data, in which each data describes what a ListItem should contain, how can I dynamically create and return a List of ListItems? Each of the ListItem is different (e.g. some have buttons, some dont)
const listData = [
{
"isClickable":true,
"horizontalComponents":[
{
"type": "image",
"data": {
"url": "http://tiny.co/foobar123"
}
},
{
"type": "text",
"componentData": {
"content": "This is a descriptive text. To view more please click the button on the right."
}
},
{
"type": "button",
"componentData": {
"buttonString": "View More"
}
}
]
}
];
listData.forEach(itemData => {
var columns: typeof ListItemText[] = [];
itemData.horizontalComponents.forEach(component => {
if (component.type == "text") {
columns.push(
<ListItemText primary={`Line item foo`} />
)
}
})
})