I have within a component:
useEffect(() => {
setcustomgearUpdate(data[0]?.Brand);
}, [data])
And then when onChange for a form field:
const values = [...customgearUpdate];
if (e.target.name === "Brand") {
values[i].label = e.target.value.toUpperCase();
values[i].value = e.target.value.toUpperCase();
}
setcustomgearUpdate(values);
This works fine, but I want to use:
setDirty(true)
within this onChange const. When I do, it re-renders the fields when you change a value and then you need to click back into the field to enter the value again. How can I prevent this from happening?
Without the setDirty, the form operates as intended.