I've created an component that returns an input
const SimpleField = ({ placeholder, id, type }: { placeholder: string; id: string; type: string }) => {
return(
<input type={type} placeholder={placeholder} id={id} onChange={handleInputChange} value={formData[id]}/>
)
}
But everytime I type something in, it loses focus (Deselects). The input is correctly registered and I can continue writing clicking between each letter.
This is my handleInputChange function:
const handleInputChange = (e: ChangeEvent<HTMLInputElement | HTMLSelectElement>) => {
e.persist();
const { id, value } = e.target;
setFormData({
...formData,
[id]: value,
});
};
Any explanation would be very appreciated π