Skip to content
Discussion options

You must be logged in to vote

I think the problem is due to calling reset and trigger at the same time.

related example:

import React from "react";
import { useForm, useFieldArray, Controller } from "./src";

function App() {
  const {
    register,
    handleSubmit,
    reset,
    formState: { isSubmitSuccessful }
  } = useForm({ defaultValues: { something: "anything" } });

  const onSubmit = (data) => {
    console.log(data);
  };

  React.useEffect(() => {
    if (formState.isSubmitSuccessful) {
      reset({ something: '' });
    }
  }, [formState, submittedData, reset]);

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input {...register("something")} />
      <input type="submit" />
    </form>
  );

Replies: 2 comments 12 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by bluebill1049
Comment options

You must be logged in to vote
12 replies
@bluebill1049
Comment options

@mic4ael
Comment options

@bluebill1049
Comment options

@mic4ael
Comment options

@mic4ael
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants