score:1

this happens because in your onchange method, you are changing inputfields variable, where as your getlinks method changes links variable, which is being rendered on the screen.

if you want to set an initial value, and then allow the user to change it, change your input to :

<input classname="form-control" defaultvalue={link.name} 
 value={inputfields.name} type="text" name="name" placeholder="name" onchange={changehandler} />

likewise change for your other input, if you do not want the user to change the value later on, it's often better to add disable in the input to avoid confusing people. 🙂

i know that this has been done so that you can create a minimal reproducible example for us, but i would have directly called setinputfields in the axios.get section to avoid this problem in the first place, however, if not possible, use the defaultvalue and value as i've shown above.


Related Query

More Query from same tag