React Form Component onSubmit Handler Not Working

后端 未结 4 749
滥情空心
滥情空心 2021-02-07 14:04

I have the following React component:

class Form extends React.Component {
  handleSubmit(e) {
    e.preventDefault();

           


        
4条回答
  •  失恋的感觉
    2021-02-07 14:17

    One obvious piece of information: do not forget to include your button inside the

    . I got stuck for a while until I figured out I had put my submit button outside my form, like this:

      
        
                  
      
    

    hence the onSubmit event was not being called, and would never be.

提交回复
热议问题