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