TanStackT
TanStack4mo ago
8 replies
foolish-indigo

How to update defaultValues?

I have two components: one of them is a list of entries, and the other one is details of the selected entry. It accepts id of the selected entry as a prop, loads existing values with TSQuery, and uses them as defaultValues.

Simple reproduction:
https://stackblitz.com/edit/vitejs-vite-ainjeqwv?file=src%2FApp.tsx

I change locale in the details component from default ("Ja") to different one ("En"), then switch to another entry in the list component.
The locale value resets to default one, "Ja", (because of form.reset()), but somehow, the fields inside the <form.Subscribe> are now having values of the previous locale ("En").
i.e. the locale field shows the correct, default locale (Ja), but values of the dependent fields are actually are from different locale - the locale that was previously selected in the previous entry (En).
StackBlitzAnton
Next generation frontend tooling. It&#39;s fast!
TSForm reset issue - StackBlitz
Was this page helpful?