1

My React based app contains a form and somewhere along the way it stopped working, the onSubmit even was no longer fired and the form was just simply submitted with a new http request. While trying to isolate the problem I stripped my whole app to the following snippet (which is actually this jsfiddle taken from another question):

import React from 'react' var OnSubmitTest = React.createClass({ render: function () { var doSomething = function () { alert('it works!'); } return <form onSubmit={doSomething}> <button>Click me</button> </form>; } }); React.render(<OnSubmitTest/>, document.body); 

The script on jsfiddle works as it should: the message is alerted just before the form is actually submitted. I get no alert in my app, though. If I add e.preventDefault() the jsfiddle form is not submitted at all, my form is.

The difference is that I build my app using webpack and babel from es6 but it's hard to believe that this could have any impact on this matter.

Any idea what might be the reason? What should I try next to debug that?

Update: JSFiddle showing the problem. The linked file is the webpack output (not uglified in any way to keep it readable, that's why it's so huge). You can find my code (compiled) starting on the line 53.

2
  • Maybe you can copy/paste the generated JS that doesn’t work into a fiddle? It’s hard to debug something that we cannot see. Commented May 8, 2015 at 10:41
  • See the link. The webpack output is huge and jsfiddle couldn't handle it, so I had to add it from the outside (as gist). Commented May 8, 2015 at 11:54

1 Answer 1

1

Mystery solved: I forgot to mark the node_modules directory as excluded (I use IntelliJ IDEA) so when I used refactoring to change some variable name form to something else, the IDE eagerly refactored the whole React and replaced all occurrences of form with the new value.

I fixed it by reinstalling all npm dependencies.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.