title: Resetting a reactjs form after submission
body: <p>I have created a reactjs form that sends data to a django rest api successfully. I want to reset the form after the button has been clicked but it keeps giving me an error saying &quot;this.props.resetState() is not a function. Is there something that can be done to reset all the inputs of the form created after submission?</p>
  <pre><code>import React, { Component } from &quot;react&quot;;
  import { Button, Form, FormGroup, Input, Label } from &quot;reactstrap&quot;;
  
  import axios from &quot;axios&quot;;
  
  import { API_URL } from &quot;../constants&quot;;
  
  class ClientForm extends React.Component {
      constructor(props) {
          super(props);
          this.state = {
              pk: 0,
              name: &quot;&quot;,
              email: &quot;&quot;,
              business_name: &quot;&quot;,
              country: &quot;&quot;,
          };
      }
  
      componentDidMount() {
          if (this.props.client) {
              const {
                  pk,
                  name,
                  email,
                  phone,
                  business_name,
                  country,
              } = this.props.client;
              this.setState(pk, name, document, email, phone);
          }
      }
  
      onChange = (e) =&gt; {
          this.setState({ [e.target.name]: e.target.value });
      };
  
      createClient = (e) =&gt; {
          e.preventDefault();
          axios.post(API_URL, this.state).then(() =&gt; {
              this.props.reset();
              this.props.toggle();
          });
      };
  
      editClient = (e) =&gt; {
          e.preventDefault();
          axios.put(API_URL + this.state.pk, this.state).then(() =&gt; {
              this.props.reset();
              this.props.toggle();
          });
      };
  
      defaultIfEmpty = (value) =&gt; {
          return value === &quot; &quot; ? &quot; &quot; : value;
      };
  
      render() {
          return (
              &lt;Form onSubmit={this.props.client ? this.editClient : this.createClient}&gt;
                  &lt;FormGroup&gt;
                      &lt;Label for=&quot;name&quot;&gt;Name:&lt;/Label&gt;
                      &lt;Input
                          type=&quot;text&quot;
                          name=&quot;name&quot;
                          onChange={this.onChange}
                          value={this.defaultIfEmpty(this.state.name)}
                      /&gt;
                  &lt;/FormGroup&gt;
                  &lt;FormGroup&gt;
                      &lt;Label for=&quot;email&quot;&gt;Email:&lt;/Label&gt;
                      &lt;Input
                          type=&quot;email&quot;
                          name=&quot;email&quot;
                          onChange={this.onChange}
                          value={this.defaultIfEmpty(this.state.email)}
                      /&gt;
                  &lt;/FormGroup&gt;
                  &lt;FormGroup&gt;
                      &lt;Label for=&quot;phone&quot;&gt;Phone Number:&lt;/Label&gt;
                      &lt;Input
                          type=&quot;text&quot;
                          name=&quot;phone&quot;
                          onChange={this.onChange}
                          value={this.defaultIfEmpty(this.state.phone)}
                      /&gt;
                  &lt;/FormGroup&gt;
                  &lt;FormGroup&gt;
                      &lt;Label for=&quot;business_name&quot;&gt;Business Name:&lt;/Label&gt;
                      &lt;Input
                          type=&quot;text&quot;
                          name=&quot;business_name&quot;
                          onChange={this.onChange}
                          value={this.defaultIfEmpty(this.state.business_name)}
                      /&gt;
                  &lt;/FormGroup&gt;
                  &lt;FormGroup&gt;
                      &lt;Label for=&quot;country&quot;&gt;Country:&lt;/Label&gt;
                      &lt;Input
                          type=&quot;text&quot;
                          name=&quot;country&quot;
                          onChange={this.onChange}
                          value={this.defaultIfEmpty(this.state.country)}
                      /&gt;
                  &lt;/FormGroup&gt;
                  &lt;Button&gt;Send&lt;/Button&gt;
              &lt;/Form&gt;
          );
      }
  }
  
  export default ClientForm;
  </code></pre>