@modular-forms/react
Version:
The modular and type-safe form library for React
17 lines (16 loc) • 548 B
JavaScript
import { initializeFieldStore } from './initializeFieldStore';
/**
* Sets the store of a field to the specified state.
*
* @param form The form of the field.
* @param name The name of the field.
* @param state The new state to be set.
*/
export function setFieldState(form, name, state) {
const field = initializeFieldStore(form, name);
field.startValue.value = state.startValue;
field.value.value = state.value;
field.error.value = state.error;
field.touched.value = state.touched;
field.dirty.value = state.dirty;
}