'How to receive all data (array) from dynamic input in react.js?
I am trying to receive data from a dynamic input (article), but it returns only an array with the two first element, I do not understand why, because I receive data from another dynamic input (chapitre) with no problems?
{
chapitreList.map(
(partItem, index) => {
return (
<div key={index}>
<label for="namec"> chapitre {index+1} :</label>
<input type="text" name='namec' id='namec' className ="form-control" value={partItem.chapitreName} />
<input type="number"
name='soldc'
id='soldc'
className ="form-control"
placeholder={partItem.chapitreDepense}
onChange={(e) =>
setchapitresolde((prev) => {
prev[index] = e.target.value;
return [...prev];
}
)
}
/>
<br />
{
partItem.articleList.map(
(artItem, inde) => {
return (
<div key={inde}>
<label for="namec"> article {inde+1} :</label>
<input type="text" name='namea' id='namea' className ="form-control" value={artItem.articleName} />
<input type="number"
name='solda'
id='solda'
class="form-control input-group-lg reg_name"
placeholder={artItem.articleDepense}
onChange={(e) =>
setarticlesolde((pre) => {
pre[inde] = e.target.value;
return [...pre];
})
}
/>
</div>
)
}
)
}
</div>
)
}
)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
