React Hook Form's useForm() not accepting defaultValues after re-rendering with new data
I'm wondering if anyone has experience with I'm collaborating on a project where I'm migrating some code and I've been struggling with this for a few days now and could really use some help. I'm facing an issue where I'm trying to set default values in React Hook Form using the `useForm()` hook, but it seems that after the initial render, the default values aren't being updated as expected when my props change. I'm using React Hook Form version 7.0.0 and my form structure looks something like this: ```javascript import React, { useEffect } from 'react'; import { useForm } from 'react-hook-form'; const MyForm = ({ initialData }) => { const { register, handleSubmit, reset } = useForm({ defaultValues: initialData }); useEffect(() => { reset(initialData); }, [initialData, reset]); const onSubmit = data => { console.log(data); }; return ( <form onSubmit={handleSubmit(onSubmit)}> <input {...register('name')} /> <input {...register('age')} /> <button type="submit">Submit</button> </form> ); }; export default MyForm; ``` The issue arises when `initialData` prop updates, triggering a re-render. I expect the form fields to update accordingly with the new values, but they remain blank or revert to their initial state. The `reset` function is being called in the `useEffect`, so I'm not sure why the form isn't reflecting the updated values. I've also tried moving the `reset` call outside of `useEffect` and directly inside the form component, but it didn't help. Also, I've checked that `initialData` is indeed changing by logging it in the console. Any ideas on how to ensure the form fields reflect the updated `initialData`? Is there something I'm missing regarding how `defaultValues` works with React Hook Form? Any help would be appreciated! For context: I'm using Javascript on Windows. What am I doing wrong? I'm working on a mobile app that needs to handle this. My team is using Javascript for this microservice. I've been using Javascript for about a year now. I'm open to any suggestions.