Skip to content

API reference > @kontsedal/olas-core > createFieldArray

createFieldArray() function ​

A dynamic list of fields or forms (§8.5).

ts
const lines = createFieldArray(ctx, (initial?: string) => createField(ctx, initial ?? ''))

add(value) and insert(index, value) pass value to the factory, so a factory that ignores its argument builds every item from its own default.

Signature:

typescript
export declare function createFieldArray<I extends Field<any> | Form<any>>(ctx: Ctx, itemFactory: (initial?: ItemInitial<I>) => I, options?: FieldArrayOptions<I>): FieldArray<I>;

Parameters ​

Parameter

Type

Description

ctx

Ctx

itemFactory

(initial?: ItemInitial<I>) => I

options

FieldArrayOptions<I>

(Optional)

Returns:

FieldArray<I>

Released under the MIT License.