Unexpected Reset of Form Values in Next.js Using React Hook Form
I'm trying to implement I'm experiencing an scenario with form values resetting unexpectedly when I submit a form using React Hook Form in my Next.js application... The form includes various fields like text inputs, a checkbox, and a file upload. After submission, instead of maintaining the input values, the entire form resets to its initial state. I initially set up my form like this: ```javascript import { useForm } from 'react-hook-form'; const MyForm = () => { const { register, handleSubmit, reset } = useForm(); const onSubmit = data => { console.log(data); // Simulating a form submission // API call can be added here reset(); // This is causing the scenario }; return ( <form onSubmit={handleSubmit(onSubmit)}> <input {...register('name')} placeholder="Name" /> <input type="checkbox" {...register('subscribe')} /> <input type="file" {...register('file')} /> <button type="submit">Submit</button> </form> ); }; ``` The question seems to be that I'm calling `reset()` right after the console log within the `onSubmit` function. However, I expected that this would only reset the form if I manually wanted to clear it after a successful submission, not reset it on every submit action. I've tried removing the `reset()` function and the form retains the values, but I want to ensure that I can clear the form when the submission is successful. How can I achieve this without the form resetting unexpectedly? Am I missing something in the process of managing state with React Hook Form? Any insights would be greatly appreciated! I'm working on a microservice that needs to handle this. The project is a desktop app built with Javascript. Could someone point me to the right documentation?