Reputation: 33
this is a sample in code sand box
https://codesandbox.io/s/restless-shadow-iiw4p?file=/src/App.jsx
I want to create table that can be added. However can not control input value.
How can I control multiple input object value in map?
Upvotes: 1
Views: 247
Reputation: 226
In your code sample you did not call the setValues()
function. That's why you could not control the input. Here are some modifications to your code:
const inputName = (index, event) => {
let tempValues = [...values];
tempValues[index].name = event.target.value;
setValues(tempValues);
};
I hope this code will work now. I have tested it in your codesandbox example also. here is the link to that: https://codesandbox.io/s/purple-water-d74x5?file=/src/App.jsx
Upvotes: 1