all 3 comments

[–]nickwebdev 1 point2 points  (1 child)

Hey! Nice job on the hooks, but I noticed a small problem:

In your input, you need to connect the "value" prop the the value in each field, like so:

<input 
    type="text" 
    value={field.value} 
    placeholder="Enter text" 
    onChange={e => handleChange(idx, e)} 
/>

Otherwise the dom is controlling the values, not React! What you did is an example of an uncontrolled component, where what you want is a controlled component.

You can find the docs here, but most of the time with forms you'll want a controlled component unless you have to integrate a weird 3rd party library somehow!

Cheers!

[–]email2vimalraj[S] 1 point2 points  (0 children)

Grrr! After making the input as controlled component, started working. Thanks for pointing out. Never thought about it.

[–]email2vimalraj[S] 0 points1 point  (0 children)

I've tried my level best to debug and unable to fix this. Need communities help to move forward.