From e4077b39b7f2fbdce465b48a10775f7fe10a11e0 Mon Sep 17 00:00:00 2001 From: Corbin Crutchley Date: Mon, 28 Aug 2023 18:16:55 -0700 Subject: [PATCH] fix: maximum depth exceeded should no longer occur --- packages/form-core/src/FieldApi.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/form-core/src/FieldApi.ts b/packages/form-core/src/FieldApi.ts index 9571ac19f..061ad78ac 100644 --- a/packages/form-core/src/FieldApi.ts +++ b/packages/form-core/src/FieldApi.ts @@ -125,10 +125,6 @@ export class FieldApi { ? state.meta.error : undefined - if (state.value !== this.prevState.value) { - this.validate('change', state.value as never) - } - this.prevState = state this.state = state }, @@ -206,17 +202,13 @@ export class FieldApi { getValue = (): typeof this._tdata => { return this.form.getFieldValue(this.name) } + setValue = ( updater: Updater, options?: { touch?: boolean; notify?: boolean }, ) => { - this.form.setFieldValue(this.name, updater as any, options) - this.store.setState((prev) => { - return { - ...prev, - value: updater as any, - } - }) + this.form.setFieldValue(this.name, updater as never, options) + this.validate('change', this.state.value) } getMeta = (): FieldMeta => this.form.getFieldMeta(this.name) @@ -250,7 +242,7 @@ export class FieldApi { form: this.form, }) - validateSync = async (value = this.state.value, cause: ValidationCause) => { + validateSync = (value = this.state.value, cause: ValidationCause) => { const { onChange, onBlur } = this.options const validate = cause === 'submit' ? undefined : cause === 'change' ? onChange : onBlur