Skip to content

Commit 0ef264a

Browse files
committed
Fix undefined array crash when using useArrayField
1 parent 32d5e4d commit 0ef264a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.2.1 (25/06/2021)
2+
3+
- Fix crash on undefined/null array when using useArrayField.
4+
15
# 2.2.0 (9/05/2021)
26

37
- `innerRef` prop on `Field` and `FieldError`

src/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export function useArrayField<
157157
useEffect(() => {
158158
let id = parentForm.listen(name, () => {
159159
let val = parentForm.values[name] as any;
160-
if (val.length !== oldLength.current) {
160+
if (Array.isArray(val) && val.length !== oldLength.current) {
161161
setRender((i) => i + 1);
162162
oldLength.current = val.length;
163163
}

0 commit comments

Comments
 (0)