Skip to content
Source
Sign inSign up
TanStack/form

fix(react-form): [v2] provide field context inside app form `ArrayField` #2434

Mergedkkatalz(GitHub profile, opens in a new tab)merged 2 commits intoalpha fromrefs/pull/2434/headmerged by LeCarbonator(GitHub profile, opens in a new tab)

Showing 7 changed files with 89 additions and 3 deletions (loading 4).

x
0 of 7 viewed, 7 left
6 additions and 0 deletions.changeset/quiet-arrays-share.mdAdded
View file
@@ -0,0 +1,6 @@
+---
+'@tanstack/react-form': patch
+'@tanstack/preact-form': patch
+---
+​
+Provide the field context inside App Form `ArrayField`, so registered field components render there instead of throwing.
13 additions and 2 deletionspackages/preact-form/src/AppForm/Components.lib.tsxModified
View file
@@ -3,7 +3,10 @@
import { InternalFormGroupApi } from '@tanstack/form-core/internals'
import { attachPreactFormComponents } from '../PreactForm/Components.lib'
import { useField } from '../PreactForm/useField.lib'
-import { useValueFieldSubscription } from '../PreactForm/fieldSubscriptions.lib'
+import {
+ useArrayFieldSubscription,
+ useValueFieldSubscription,
+} from '../PreactForm/fieldSubscriptions.lib'
import { Subscribe } from '../Subscribe.public'
import { FieldContext, FormContext } from './contexts.lib'
import type { AnyInternalFormApi } from '@tanstack/form-core/internals'
@@ -36,6 +39,13 @@
form,
fieldComponents,
) as AnyPreactAppFormApi['Field']
+ const arrayField = createFieldWithContext(
+ form,
+ fieldComponents,
+ useArrayFieldSubscription,