Skip to content

Commit bccc22a

Browse files
authored
fix: assign distinct initial values to both errors and warnings to prevent isEqual from encountering circular references (#650)
1 parent f9ac280 commit bccc22a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Field.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
} from './utils/valueUtil';
3131

3232
const EMPTY_ERRORS: any[] = [];
33+
const EMPTY_WARNINGS: any[] = [];
3334

3435
export type ShouldUpdate<Values = any> =
3536
| boolean
@@ -146,7 +147,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
146147
private prevValidating: boolean;
147148

148149
private errors: string[] = EMPTY_ERRORS;
149-
private warnings: string[] = EMPTY_ERRORS;
150+
private warnings: string[] = EMPTY_WARNINGS;
150151

151152
// ============================== Subscriptions ==============================
152153
constructor(props: InternalFieldProps) {
@@ -268,7 +269,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
268269
this.dirty = true;
269270
this.validatePromise = null;
270271
this.errors = EMPTY_ERRORS;
271-
this.warnings = EMPTY_ERRORS;
272+
this.warnings = EMPTY_WARNINGS;
272273
this.triggerMetaEvent();
273274
}
274275

@@ -280,7 +281,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
280281
this.dirty = false;
281282
this.validatePromise = undefined;
282283
this.errors = EMPTY_ERRORS;
283-
this.warnings = EMPTY_ERRORS;
284+
this.warnings = EMPTY_WARNINGS;
284285
this.triggerMetaEvent();
285286

286287
onReset?.();
@@ -320,7 +321,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
320321
this.errors = data.errors || EMPTY_ERRORS;
321322
}
322323
if ('warnings' in data) {
323-
this.warnings = data.warnings || EMPTY_ERRORS;
324+
this.warnings = data.warnings || EMPTY_WARNINGS;
324325
}
325326
this.dirty = true;
326327

@@ -474,7 +475,7 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F
474475
this.validatePromise = rootPromise;
475476
this.dirty = true;
476477
this.errors = EMPTY_ERRORS;
477-
this.warnings = EMPTY_ERRORS;
478+
this.warnings = EMPTY_WARNINGS;
478479
this.triggerMetaEvent();
479480

480481
// Force trigger re-render since we need sync renderProps with new meta

0 commit comments

Comments
 (0)