Skip to main content

useRepeaterField

Field hook to access the data of a repeater field with the type repeater.

Arguments

The hook can take an object as argument with the following properties.

FieldTypeDescription
fieldstringThe name of the field

Returns

An array of objects. Each object has an attribute for each field that is defined for a repeater item. If a field has no defaultValue or no value defined, the attribute might not be present. These values are the raw values behind a field. It is recommended to use the Repeater component to iterate of repeater items in order to use the other field hooks for each repeater item.

Example

src/widgets/example/Example.tsx
import React from 'react'
import {useRepeaterField} from '@modbros/dashboard-sdk'

interface MyExampleRepeaterItem {
title?: string;
someLimit?: number;
}

export default function Example() {
const items: MyExampleRepeaterItems[] = useRepeaterField<MyExampleRepeaterItem>({field: 'example'})

return items.map((item, index) => (
<span key={index}>{item.title}: {item.someLimit}</span>
))
}