UNPKG

@modular-forms/solid

Version:

The modular and type-safe form library for SolidJS

23 lines (22 loc) 622 B
import { untrack } from 'solid-js'; import { getFieldStore } from './getFieldStore'; /** * Returns the RAW state of the field. * * @param form The form of the field. * @param name The name of the field. * * @returns The state of the field. */ export function getFieldState(form, name) { const field = getFieldStore(form, name); return field ? untrack(() => ({ startValue: field.startValue.get(), value: field.value.get(), error: field.error.get(), touched: field.touched.get(), dirty: field.dirty.get(), })) : undefined; }