@modular-forms/solid
Version:
The modular and type-safe form library for SolidJS
23 lines (22 loc) • 701 B
JavaScript
import { untrack } from 'solid-js';
import { getFieldArrayStore } from './getFieldArrayStore';
/**
* Returns the RAW state of the field array.
*
* @param form The form of the field array.
* @param name The name of the field array.
*
* @returns The state of the field array.
*/
export function getFieldArrayState(form, name) {
const fieldArray = getFieldArrayStore(form, name);
return fieldArray
? untrack(() => ({
startItems: fieldArray.startItems.get(),
items: fieldArray.items.get(),
error: fieldArray.error.get(),
touched: fieldArray.touched.get(),
dirty: fieldArray.dirty.get(),
}))
: undefined;
}