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

Commit

Permalink
Fix(useForm): fix variable typo
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyshen committed Dec 28, 2020
1 parent d2072e4 commit 3a24549
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-pumas-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-cool-form": patch
---

Fix(useForm): fix variable typo
14 changes: 7 additions & 7 deletions src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ export default <V extends FormValues = FormValues>({

if (isCheckboxInput(field)) {
if (options) {
const checkboxs = options as HTMLInputElement[];
const checkboxes = options as HTMLInputElement[];

if (options.length > 1) {
value = checkboxs
value = checkboxes
.filter((checkbox) => checkbox.checked)
.map((checkbox) => checkbox.value);
} else {
value = checkboxs[0].checked;
value = checkboxes[0].checked;
}
} else {
let checkValues = get(stateRef.current.values, field.name);
Expand Down Expand Up @@ -236,16 +236,16 @@ export default <V extends FormValues = FormValues>({
const { field, options } = fieldsRef.current[name];

if (isCheckboxInput(field)) {
const checkboxs = options as HTMLInputElement[];
const checkboxes = options as HTMLInputElement[];

if (checkboxs.length > 1) {
checkboxs.forEach((checkbox) => {
if (checkboxes.length > 1) {
checkboxes.forEach((checkbox) => {
checkbox.checked = Array.isArray(value)
? value.includes(checkbox.value)
: !!value;
});
} else {
checkboxs[0].checked = !!value;
checkboxes[0].checked = !!value;
}
} else if (isRadioInput(field)) {
(options as HTMLInputElement[]).forEach((radio) => {
Expand Down

0 comments on commit 3a24549

Please sign in to comment.