Good evening, I have a onChange function name handleChange for a number of dinamically created inputs. What this does is to receive the event and then it does as it follows:
const handleChange = (e) => {
const updatedValues = [...values];
updatedValues[e.target.dataset.id] = []
updatedValues[e.target.dataset.id][e.target.name] = e.target.value;
setValues(updatedValues);
}
The first issue i'm finding here is that is building the object with the following structure:
[
{name: "some_name"}
],
[
{lastname: "some_lastname"}
],
[
{email: "some_data"}
],
[
{phone: "some_phone"}
]
But the structure I want goes like this:
[
{ name: "some_name", lastname: "some_lastname", email: "some_email", phone: "some_phone"}
]
Next thing I wanna do, is to store NESTED components on new property named nested. I want it to be like this:
[
{ name: "some_name", lastname: "some_lastname", email: "some_email", phone: "some_phone", nested: [
{ value: "some_value", value2: "some_value2", value3: "some_value3"}
]}
]
The nested ones are being grabbed from a box of inputs. The box has a className of "nested" and it is at the same level as the first inputs. Inside of it I have the inputs that I want to nest.
Could you please help me with this?