Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Fix(useFieldArray): fields not updated by helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyshen committed Mar 20, 2021
1 parent 6395f0b commit 1eee601
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-countries-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-cool-form": patch
---

Fix(useFieldArray): fields not updated by helper methods
15 changes: 8 additions & 7 deletions src/useFieldArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ export default <T = any, V extends FormValues = FormValues>(
};
}, [initialStateRef, name, removeField, setDefaultValue, shouldRemoveField]);

fieldArrayRef.current[name] = {
reset: () => {
setFields(getFields());
setNodeValue();
},
fields: {},
};
if (!fieldArrayRef.current[name])
fieldArrayRef.current[name] = {
reset: () => {
setFields(getFields());
setNodeValue();
},
fields: {},
};
if (validate) fieldValidatorsRef.current[name] = validate;

const setState = useCallback(
Expand Down

0 comments on commit 1eee601

Please sign in to comment.