Replies: 1 comment
-
|
I guess this is related: react-hook-form/react-hook-form#11177 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a form with a custom component, all hooked up via a
Controller. This part is fine, it shows the current value and it can be edited and submitted. I usedefaultValuesto set the value of this custom component based on data returned by a loader. Everything works.I then have a separate form on the same page for a delete action, it is independent of the form above. This form simply triggers a delete action on a different route. It uses a fetcher. This does NOT use remix-hook-form, it's a Remix
Form.As is expected with Remix, the post to that action triggers the loaders to re-run and deliver the updated data to the application. This part also works, I can see the loaders run, and I can see (in logs) new values in my component (the deleted item has been removed).
But, despite having new values provided by the loader, and again I can see these new values in the logs of the component that renders the form, this form (the one that uses remix-hook-form) apparently keeps the previous values, it does not update to remove the deleted value. I can see inside the controller that the field.value prop still has the previous values.
Essentially, it seems like the useRemixForm hook does not update when the defaultValues change.
What am I doing wrong?
I added
key={JSON.stringify(value)}to my form as a hack, and this works, but it has side effects like breaking the delete animation, a flash of unwanted content when the component re-renders and so on,.Beta Was this translation helpful? Give feedback.
All reactions