Skip to content

Commit

Permalink
code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebill1049 committed Apr 1, 2020
1 parent fd3160b commit 19dfc1a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/useFieldArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ export const useFieldArray = <
get(defaultValuesRef.current, name, []),
);
const isNameKey = isKey(name);
if (isNameKey) {
fieldArrayDefaultValues.current[name] = memoizedDefaultValues.current;
}
const [fields, setField] = useState<
Partial<ArrayField<FormArrayValues, KeyName>>[]
>(mapIds(memoizedDefaultValues.current, keyName));
Expand All @@ -69,6 +66,10 @@ export const useFieldArray = <

allFields.current = fields;

if (isNameKey) {
fieldArrayDefaultValues.current[name] = memoizedDefaultValues.current;
}

const appendValueWithKey = (value: Partial<FormArrayValues>[]) =>
value.map((v: Partial<FormArrayValues>) => appendId(v, keyName));

Expand Down

0 comments on commit 19dfc1a

Please sign in to comment.