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

Commit

Permalink
refactor(useForm): move arrayToObject to useForm
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyshen committed Nov 9, 2020
1 parent b784db1 commit c642dfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
import useLatest from "./useLatest";
import useFormState from "./useFormState";
import {
arrayToObject,
deepMerge,
get,
isArray,
Expand All @@ -51,6 +50,12 @@ import {
const useUniversalLayoutEffect =
typeof window === "undefined" ? useEffect : useLayoutEffect;

const arrayToObject = (arr: any[]): Record<string, boolean> =>
arr.reduce((obj, key) => {
obj[key] = true;
return obj;
}, {});

const isFieldElement = ({ tagName }: HTMLElement) =>
/INPUT|TEXTAREA|SELECT/.test(tagName);

Expand Down
6 changes: 0 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ export const warn = (...args: any[]): void => {
if (__DEV__) console.warn(...args);
};

export const arrayToObject = (arr: any[]): Record<string, boolean> =>
arr.reduce((obj, key) => {
obj[key] = true;
return obj;
}, {});

export const isNumberField = (field: FieldElement): field is HTMLInputElement =>
field.type === "number";

Expand Down

0 comments on commit c642dfa

Please sign in to comment.