question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Form submission canceled because the form is not connected

See original GitHub issue

The WARNING: “Form submission canceled because the form is not connected” appears on the console when the user clicks in a cancel button that has the following code:

  handleCancel = (evt) => {
    this.props.reset();
    this.props.router.replace('/');
  }

What is the right way to CANCEL the form submission and navigating away from the page that has a redux-form?

I am using:

  • redux-form: ^6.5.0
  • react-router: ^3.0.2
  • semantic-ui-react: ^0.66.0
  • apollo-client: ^0.8.7

When the user clicks in the submit button, everything works fine (data is mutate using Apollo Client and navigating away from the page that has the form): no warning is shown

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

197reactions
erikrascommented, Mar 13, 2017

That’s pretty strange. My guess is that you have:

<button onClick={this.handleCancel}>Cancel</button>

and it should be

<button type="button" onClick={this.handleCancel}>Cancel</button>
        ^^^^^^^^^^^^^

I think that most browsers default a <button/> to be a submit button, so you are both trying to submit the form and navigate away.

Another option is to call evt.preventDefault() in your handleCancel() function.

5reactions
McChubbycommented, Jan 10, 2018

Adding type=“button” worked great, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Error "Form submission canceled because the form is ...
Form submission canceled because the form is not connected. The simple fix is: Use onSubmit handler on the form; Remove the onClick handler...
Read more >
Form submission cancelled because the form is not connected
The components seem to be working fine, but on console it shows an error saying Form submission cancelled because the form is not...
Read more >
Form Submission Canceled Because the Form Is Not Connected
Form submission canceled because the form is not connected will ruin your day without clues of the cause. Read this post to see...
Read more >
form submission canceled because the form is not connected
So, while clicking on the button, the onclick function is firing and the form is NOT submitting, and the console is printing –....
Read more >
JavaScript : Getting Error "Form submission canceled because ...
JavaScript : Getting Error " Form submission canceled because the form is not connected " [ Gift : Animated Search Engine ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found