React generated button on my form keeps refreshing the page

Posted by Jessica Taylor | Updated on

React generated button on my form keeps refreshing the page. Sounds to me like a delegation issue – I’ll bet #chat isn’t in the DOM when you are creating the submit handler.

Try delegating the submit to the document (and preventing the default action):

Here is another example:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers