# Why setting onFormSubmit prevents calling onFormSubmitted?

**URL:** <https://community.hubspot.com/t/why-setting-onformsubmit-prevents-calling-onformsubmitted/128195>\
**Category:** APIs & Integrations\
**Tags:** companies\
**Created:** [March 18, 2025, 6:13pm UTC](https://community.hubspot.com/t/why-setting-onformsubmit-prevents-calling-onformsubmitted/128195 "2025-03-18T18:13:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JSiv](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@JSiv](https://community.hubspot.com/u/JSiv)\
**Post date:** [March 18, 2025, 6:13pm UTC](https://community.hubspot.com/t/why-setting-onformsubmit-prevents-calling-onformsubmitted/128195/1 "2025-03-18T18:13:16Z")

</div>

Setting the onFormSubmit callback, prevents

1) Redirection, if configured in Hubspot

2) Following events, like onFormSubmitted

I tried multiple times, I tried returning true, etc.

`onFormSubmit: (form: any) => { setFormSubmitted(true); setFormData( ... )}`

---

<div class="post-metadata">

**Author:** ![JSiv](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@JSiv](https://community.hubspot.com/u/JSiv)\
**Post date:** [March 18, 2025, 9:44pm UTC](https://community.hubspot.com/t/why-setting-onformsubmit-prevents-calling-onformsubmitted/128195/2 "2025-03-18T21:44:42Z")

</div>

Issue was that the setState for formSubmitted actually made React to unmount the form. So the rest of the callback were erroring I guess and execution stopped.

This could be used to prevent the redirection set in the form config itself, but idk which side effects it would have
