diff --git a/src/atoms/list-atom/listAtom.ts b/src/atoms/list-atom/listAtom.ts index 3e6a3cf..fe60048 100644 --- a/src/atoms/list-atom/listAtom.ts +++ b/src/atoms/list-atom/listAtom.ts @@ -133,10 +133,7 @@ export function listAtom< const formLists = get(_formListAtom); return formLists.map((formAtom) => { - const formAtoms = get(formAtom); - const { fields } = get(formAtoms.fields); - - return fields; + return get(get(formAtom).fields); }); }); @@ -214,14 +211,9 @@ export function listAtom< const emptyAtom = atom((get) => get(_formListAtom).length === 0); const valueAtom = atom( (get) => { - const formLists = get(_formListAtom); - - return formLists.map((formAtom) => { - const formAtoms = get(formAtom); - const { fields } = get(formAtoms.values); - - return fields as Value; - }); + return get(_formListAtom).map((formAtom) => { + return get(get(formAtom).values); + }) as Value[]; }, ( get, diff --git a/src/atoms/list-atom/listItemForm.ts b/src/atoms/list-atom/listItemForm.ts index d3dd016..161d1a5 100644 --- a/src/atoms/list-atom/listItemForm.ts +++ b/src/atoms/list-atom/listItemForm.ts @@ -97,9 +97,7 @@ type NamedFormAtom = Atom<{ ) => Promise; }>; -export type ListItemForm = NamedFormAtom<{ - fields: Fields; -}>; +export type ListItemForm = NamedFormAtom; export function listItemForm({ fields, @@ -132,7 +130,7 @@ export function listItemForm({ >; }) { const itemFormAtom: ListItemForm = extendAtom( - formAtom({ fields }) as unknown as PrimitiveFormAtom, + formAtom(fields) as unknown as PrimitiveFormAtom, (base, get) => { const nameAtom = atom((get) => { const list: ListItemForm[] = get(formListAtom);