Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-final-form - How to reset form and set state

Is there a way to reset the form and set the state at the same go? I tried the below code and it does not seem to work. Any inputs are appreciated.

<Form
    onSubmit={this.onSubmit}
    render={({handleSubmit, form, submitting, pristine, values}) => (
        <form onSubmit={handleSubmit}>
.
.
.
.

<button
    type="button"
    onClick={() => {
        form.reset;
        this.setState({"reset": true});
    }}
    disabled={submitting || pristine}
>
    Reset
</button>
</form>
like image 391
Deep Avatar asked Nov 16 '25 04:11

Deep


1 Answers

<button
  type="button"
  onClick={() => {
      form.reset();
      this.setState({"reset": true});
  }}
  disabled={submitting || pristine}
>
    Reset
</button>

I think what you missing is executing form.reset function

like image 197
Khoi Nguyen Avatar answered Nov 17 '25 20:11

Khoi Nguyen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!