Skip to content
Source
Sign inSign up
TanStack/form

fix(form-core): prevent runtime errors when using `deleteField` #1706

Mergedkusiewicz(GitHub profile, opens in a new tab)merged 7 commits intomain fromrefs/pull/1706/headmerged by LeCarbonator(GitHub profile, opens in a new tab)

Showing 3 changed files with 81 additions and 0 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/healthy-forks-live.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/form-core': patch
+---
+​
+fix(form-core): prevent runtime errors when using `deleteField`
10 additions and 0 deletionspackages/form-core/src/FormApi.tsModified
View file
@@ -1642,6 +1642,11 @@
for (const field of Object.keys(
this.state.fieldMeta,
) as DeepKeys<TFormData>[]) {
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ if (this.baseStore.state.fieldMetaBase[field] === undefined) {
+ continue
+ }
+​
const fieldMeta = this.getFieldMeta(field)
if (!fieldMeta) continue
@@ -1845,6 +1850,11 @@
for (const field of Object.keys(
this.state.fieldMeta,