I am using a state that at the start contains nothing. I want to update it with multiple input values. But when I try to do so my input value are just overwritting each other. For instance, let's say I set my input to test first then my object will be value : msg1 : 'test' but if I go in the second input and I type "test2" my object value will then be msg2 : 'test2' not the both together and that's what I want.
{
{name1:name1, value1: value1},
{name2:name2, value2:value2}
}
/* OR something like this */
{
value1: value1,
value2: value2
}
I want it to be value1:'test' value2:'test2
const [msgCount, setMsgCount] = useState({});
const handleChange = name => value => {
setTicketCount({name,value});
}
<input type='number' onChange={handleChange('msg'+1)} />
<input type='number' onChange={handleChange('msg'+2)} />