title: How to reset the form after submit or after clicking on cancel button using formik
body: <pre><code>const TextForm: React.FunctionComponent&lt;Props&gt; = (props) =&gt; { 
  
  const formError = yup.object({
      name: yup.string().required(&quot;Required&quot;),
    });
        const formValidation = (fieldName) =&gt; {
          return {
            invalid: !!form.errors[fieldName] &amp;&amp; form.touched[fieldName],
            invalidText: form.errors[fieldName],
            onBlur: form.handleBlur,
          };
        };  
   const form = useFormik({
          initialValues: {
            name,
            id,
          },
          formValidation
          formError,
          validateOnChange: true,
          validateOnMount: true,
          initialTouched: {},
        });
    
      return(
      &lt;React.Fragment&gt;
      &lt;form&gt;
       &lt;TextInput
                          id=&quot;text-input-2&quot;
                          {...validation(&quot;name&quot;)}
                          type=&quot;text&quot;
                          name = &quot;name&quot;
                          onChange={(event) =&gt; {
                            setName(event.target.value);
                            form.handleChange(event);
                          }}
                        /&gt;
      &lt;TextInput
                          id=&quot;text-input-2&quot;
                          {...validation(&quot;id&quot;)}
                          type=&quot;text&quot;
                          name = &quot;id&quot;
                          onChange={(event) =&gt; {
                            setId(event.target.value);
                          }}
                        /&gt;
      &lt;Button&gt;Clear&lt;/Button&gt;
      &lt;Button&gt;Submit&lt;/Button&gt;
      &lt;/form&gt;
      &lt;/React.Fragment&gt;
      ) 
      }
  </code></pre>
  <p>Validations in my form are working fine. But if user does not enter any field, it comes with required warning. I am trying to clear/reset the form on Clear button click ,but could not find any possible solution working. Can anyone help me with this.</p>