I have a reactjs form, on page load it will show all values from database which user can change and submit. When I am trying to change input value, it updates state but not UI.
Below is the sample code. My form has many input controls.
const [user, setUser] = useState({});
useEffect(() => {
//calling api and update state on page load
setUser(response);
}, [])
const handleChange= (e)=>{
let track= user;
track[e.target.name]=e.target.value;
setUser(track);
}
//HTML CODE
<form name='NewUser'>
<table>
<tr>
<td>
<input
className="form-control"
name="firstInput"
onChange={handleChange}
type="number"
min="0"
max="1000"
value={user.firstInput}
/>
</td>
<td>
<input
className="form-control"
name="secondInput"
onChange={handleChange}
type="number"
min="0"
max="1000"
value={user.secondInput}
/>
</td>
<tr/>
</table>
</form>