0

I was facing difficulties to make material UI payment elements dynamically so, I would like to share how I make them dynamically here is GUI you can get this code from the material UI website

enter image description here

here is the code of static data

  const rows = [
      createRow('Paperclips (Box)', 100, 1.15),
      createRow('Paper (Case)', 10, 45.99),
      createRow('Waste Basket', 2, 17.99),
    ];
Zaryab Khan
  • 73
  • 1
  • 13

1 Answers1

2

here I am supposing that you have data in the data variable, or it is coming from API

enter image description here

first, destruct array data

 const newData = data.map(({ name: name, price: price,quantity:quantity }) => ({name, price,quantity}));

Update your rows

let newArray = [] 
for(let i = 0 ;i<newData.length;i++)
{

 newArray.push(createRow(newData[i].name, newData[i].quantity, newData[i].price))

}

const rows =newArray;
TriS
  • 3,668
  • 3
  • 11
  • 25
Zaryab Khan
  • 73
  • 1
  • 13