Docyrus

SchemaRepeater

A generic repeater component for managing dynamic lists of items with reordering, adding, and removing capabilities.

iOSAndroid
Preview SchemaRepeater on your device

Scan with Expo Go

Download Expo Go, then scan the QR code to preview native components.

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-schema-repeater

Usage

import { SchemaRepeater } from '@/components/docyrus-native/schema-repeater';

type LineItem = { id: string; name: string; quantity: number };

<SchemaRepeater<LineItem>
  value={items}
  onValueChange={setItems}
  createItem={() => ({ id: String(Date.now()), name: '', quantity: 1 })}
  renderItem={(item, index, helpers) => (
    <TextInput
      value={item.name}
      onChangeText={(text) => helpers.update({ name: text })}
    />
  )}
/>

API Reference

SchemaRepeaterProps<T>

PropTypeDefaultDescription
valueT[]—Array of items to render. Each item must have an id: string field
onValueChange(items: T[]) => void—Called when items are added, removed, reordered, or updated
renderItem(item: T, index: number, helpers: SchemaRepeaterHelpers<T>) => ReactNode—Render function for each item. Receives the item, its index, and helper functions
createItem() => T—Factory function to create a new item when the add button is pressed
maxItemsnumber—Maximum number of items allowed. Add button hides when reached
minItemsnumber0Minimum number of items required. Remove button disables when reached
addLabelstringui.schemaRepeater.add (“Add”)Label text for the add button
disabledbooleanfalseDisables all interactions including add, remove, and reorder
classNamestring—Additional CSS classes

SchemaRepeaterItem

FieldTypeDescription
idstringUnique identifier required for each item

SchemaRepeaterHelpers<T>

FieldTypeDescription
remove() => voidRemoves the current item
update(updates: Partial<T>) => voidPartially updates the current item
moveUp() => voidMoves the current item up by one position
moveDown() => voidMoves the current item down by one position
isFirstbooleanWhether this is the first item in the list
isLastbooleanWhether this is the last item in the list

Form field variant

field-schemaRepeater forms use DocyFieldSchemaRepeater from @docyrus/rn-form-fields — rows of IField sub-fields rendered through DocyFieldDynamic (schema mode) or key / value pairs, with move up / down, duplicate and collapsible rows. See Form Fields.

Type Exports

TypeDescription
SchemaRepeaterProps<T>Props for SchemaRepeater component
SchemaRepeaterItemBase interface for repeater items (requires id)
SchemaRepeaterHelpers<T>Helper object passed to renderItem callback

On this page