1

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.