TanStackT
TanStack5mo ago
4 replies
foolish-indigo

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:
// ... 
<form.Subscribe
          selector={(state) => [state.values.status, state.values.locale]}
        >
          {([status, locale]) => (
            <>
              <form.AppField name={`translations.${status}.${locale}.title`}>
                {(field) => {
                  return <field.TextField label="Title" />;
                }}
              </form.AppField>
            </>
          )}
</form.Subscribe>

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?
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....
Basic Concepts and Terminology | TanStack Form React Docs
Was this page helpful?