Reactive form.Subscribe to multiple form values
Hi, I have a nested form with fields like this:
translations.<"draft" | "published">.<"en" | "ja">.title
And I want to be able to switch between the translations' draft/published and locales with switches, so I did this:
as I have seen in the docs here.
But then type of both, status
and locale
's types are resolving to union of all types, i.e. as "draft" | "published" | "en" | "ja"
... is that expected behavior?Basic Concepts and Terminology | TanStack Form React Docs
Field statesThis page introduces the basic concepts and terminology used in the @tanstack/react-form library. Familiarizing yourself with these concepts will help you better understand and work with the library....
2 Replies
afraid-scarletOP•2mo ago
Or we are supposed to use nested
<form.Subscribe >
for that?
Or is it ok to use objects, not arrays for that? selector={(state) => ({status: state.values.status, locale: state.values.locale})}
xenial-black•2mo ago
use
as const
to indicate that it‘s a tuple
otherwise typescript infers it‘s a simple array