We have created a Dynamic Add Remove Component inside a form. Whenever i delete any input field it gets deleted from the UI but in form's onValidate Function, I still see removed input's validation.
onValidate() Function returning {errors, infos} should only return existing elements on Form
But it is still persisting removed elements from form.



CC: @ShimiSun
https://codesandbox.io/s/frosty-snowflake-yfndq?file=/src/App.js:1140-1166
Replicating the issue in CodeSandBox with plain grommet.
Thank you for the CodeSandbox @ypinneka. I also created an implementation where the inputs are in an array and remove action splices the item from the array to mimic @shreyashah7's original post.
I have been able to replicate the issue with both implementations.
A couple of initial findings:
{errors: {}, infos: {}})valueState (determined by the form's context) still retains the removed input.valueState.Next steps:
What about adding something like?:
const [value, setValue, removeValue] = formContext.useFormInput(name, valueProp);
useEffect(() => return () => removeValue()), []);