I have an application when user has the possibility to toggle between the components.The idea of the application is next:
add field butt
Edit: I think setting state interferes with formVal updating.
setTimeout(() => { setFieldsOnEdit(prevIndexes => [...prevIndexes, index]); setDefaultMode(false); }, 0);
Placing it in a setTimeout resolves it.