@tanstack/form-core
Advanced tools
Comparing version 0.8.1 to 0.8.2
@@ -303,6 +303,8 @@ // src/FormApi.ts | ||
this.deleteField = (field) => { | ||
const newState = { ...this.state }; | ||
delete newState.values[field]; | ||
delete newState.fieldMeta[field]; | ||
this.store.setState((_) => newState); | ||
this.store.setState((prev) => { | ||
const newState = { ...prev }; | ||
delete newState.values[field]; | ||
delete newState.fieldMeta[field]; | ||
return newState; | ||
}); | ||
}; | ||
@@ -309,0 +311,0 @@ this.pushFieldValue = (field, value, opts) => { |
@@ -297,6 +297,8 @@ // src/FormApi.ts | ||
this.deleteField = (field) => { | ||
const newState = { ...this.state }; | ||
delete newState.values[field]; | ||
delete newState.fieldMeta[field]; | ||
this.store.setState((_) => newState); | ||
this.store.setState((prev) => { | ||
const newState = { ...prev }; | ||
delete newState.values[field]; | ||
delete newState.fieldMeta[field]; | ||
return newState; | ||
}); | ||
}; | ||
@@ -303,0 +305,0 @@ this.pushFieldValue = (field, value, opts) => { |
{ | ||
"name": "@tanstack/form-core", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"description": "Powerful, type-safe, framework agnostic forms.", | ||
@@ -5,0 +5,0 @@ "author": "tannerlinsley", |
@@ -554,7 +554,8 @@ import { Store } from '@tanstack/store' | ||
deleteField = <TField extends DeepKeys<TFormData>>(field: TField) => { | ||
const newState = { ...this.state } | ||
delete newState.values[field as keyof TFormData] | ||
delete newState.fieldMeta[field] | ||
this.store.setState((_) => newState) | ||
this.store.setState((prev) => { | ||
const newState = { ...prev } | ||
delete newState.values[field as keyof TFormData] | ||
delete newState.fieldMeta[field] | ||
return newState | ||
}) | ||
} | ||
@@ -561,0 +562,0 @@ |
@@ -614,3 +614,5 @@ import { expect, vitest } from 'vitest' | ||
expect(form.state.fieldMeta.name).toBeUndefined() | ||
expect(form.store.state.values.name).toBeUndefined() | ||
expect(form.store.state.fieldMeta.name).toBeUndefined() | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
472393
6154