Skip to content

Commit 0b5c94d

Browse files
authored
fix: maximum depth exceeded should no longer occur (#408)
1 parent 77594a6 commit 0b5c94d

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

packages/form-core/src/FieldApi.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ export class FieldApi<TData, TFormData> {
125125
? state.meta.error
126126
: undefined
127127

128-
if (state.value !== this.prevState.value) {
129-
this.validate('change', state.value as never)
130-
}
131-
132128
this.prevState = state
133129
this.state = state
134130
},
@@ -206,17 +202,13 @@ export class FieldApi<TData, TFormData> {
206202
getValue = (): typeof this._tdata => {
207203
return this.form.getFieldValue(this.name)
208204
}
205+
209206
setValue = (
210207
updater: Updater<typeof this._tdata>,
211208
options?: { touch?: boolean; notify?: boolean },
212209
) => {
213-
this.form.setFieldValue(this.name, updater as any, options)
214-
this.store.setState((prev) => {
215-
return {
216-
...prev,
217-
value: updater as any,
218-
}
219-
})
210+
this.form.setFieldValue(this.name, updater as never, options)
211+
this.validate('change', this.state.value)
220212
}
221213

222214
getMeta = (): FieldMeta => this.form.getFieldMeta(this.name)
@@ -250,7 +242,7 @@ export class FieldApi<TData, TFormData> {
250242
form: this.form,
251243
})
252244

253-
validateSync = async (value = this.state.value, cause: ValidationCause) => {
245+
validateSync = (value = this.state.value, cause: ValidationCause) => {
254246
const { onChange, onBlur } = this.options
255247
const validate =
256248
cause === 'submit' ? undefined : cause === 'change' ? onChange : onBlur

0 commit comments

Comments
 (0)