Skip to content

Commit

Permalink
fix: maximum depth exceeded should no longer occur (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchcorn authored Aug 29, 2023
1 parent 77594a6 commit 0b5c94d
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions packages/form-core/src/FieldApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ export class FieldApi<TData, TFormData> {
? state.meta.error
: undefined

if (state.value !== this.prevState.value) {
this.validate('change', state.value as never)
}

this.prevState = state
this.state = state
},
Expand Down Expand Up @@ -206,17 +202,13 @@ export class FieldApi<TData, TFormData> {
getValue = (): typeof this._tdata => {
return this.form.getFieldValue(this.name)
}

setValue = (
updater: Updater<typeof this._tdata>,
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)
Expand Down Expand Up @@ -250,7 +242,7 @@ export class FieldApi<TData, TFormData> {
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
Expand Down

0 comments on commit 0b5c94d

Please sign in to comment.