Repeater
The Repeater component allows you to repeat a group of components according to a list or dictionary.
How it works
Repeater repeats its contents for every item of a given list or dictionary. It’s similar to a for each
construct.
Each iteration is rendered with a different context, a dictionary containing the key and value for the relevant item. By default, in the variables itemId
and item
.
Food Selector example
Given the state below, the contents of Repeater will be repeated 3 times. For the first iteration, itemId
will equal Banana
, and item
will equal {"type": "fruit", "colour": "yellow"}
. Components inside Repeater will be able to access this data using references such as @{itemId}
and @{item.type}
.
Event context
When working with Repeater components, you can get the context data using the context
argument in the event handler.
Continuing with the Food Selector example above, the following handler can be linked to a Button —allowing users to add items to a list.
Binding directly to context isn’t possible
Use dynamic accessors when binding inside a Repeater. For example, articles[itemId].colour
. This will bind to a different property of articles
for every itemId
.