score:0

Accepted answer

tl;dr

handlesubmit = (e) => e.preventdefault()

<form onsubmit={this.handlesubmit} />

why?

by default, an html form will make get request to the current uri on submit, see here. also by default, a button in a form will submit it:

http://codepen.io/levithomason/pen/rpewwp

<form onsubmit="alert('submitted!')">
  <button>i'll submit</button>
  <button>me too</button>
</form>

what is happening is, react is rendering a <form /> with some <button />s inside of it and when you click them, it is making a get request to the current uri with the form data.

going out on a limb, i bet your local server that is serving your app doesn't have a handler to accept this request. going further, i bet it also has a fallback that responds with the index.html on unknown requests. this is commonplace for single page apps to allow the app's soft router to handle routing, rather than the server. this is probably causing your request for bundle.js to actually receive the index.html, hence the unexpected token.

since you've stated:

...if i don't use a form tag in above codes, it works fine...

simply preventing the form submit should solve it for you.


Related Query

More Query from same tag