Skip to content

Commit

Permalink
Fix jaredpalmer#417. Make sure an array exists or is created in Field…
Browse files Browse the repository at this point in the history
…Array.push()
  • Loading branch information
jaredpalmer committed Feb 8, 2018
1 parent f0c9b4a commit 2937582
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/FieldArray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ export class FieldArray extends React.Component<FieldArrayConfig, {}> {
};

push = (value: any) =>
this.updateArrayField((array: any[]) => [...array, value], false, false);
this.updateArrayField(
(array: any[]) => [...(array || []), value],
false,
false
);

swap = (indexA: number, indexB: number) =>
this.updateArrayField(
Expand Down

0 comments on commit 2937582

Please sign in to comment.