Issues with hiding Form in onSubmit

I am trying to remove a Form in the returned promise that i supply to the Form’s submit method. However, it keep getting a React error that makes it seem like the form itself is doing some state changes after i removed the form.

I described the issue better here:

What can i do to properly remove the form?