See the Pen Untitled by Sikandar (@Pandit0503) on CodePen.
In this updated version, we create a rows
state variable that holds an array of objects, and use the map
function to loop over the array and generate a row for each object. When the "Add" button is clicked, we create a new object with the data from the form and add it to the rows
array using the spread operator. We also reset the data
state variable to clear the form fields.