Helpers
Repeat
The repeat
helper is used to efficiently repeat an element inside a container for a given array of data. It is usually called from within the dom
updater for an Array
property:
The repeat
function takes the following arguments:
container
- the DOM node into which place the repeated elementsitems
- the array of data to use as the sourcehtml
- the HTML template that should be used for each repeated element - it must have a single root elementkeyFn
- a function that returns a unique key for each element - used for efficient re-rendering. The function is passed the item.targets
- an array oftarget
s in the element that will be updated when the item associated with this element changes, with the same definition as in theprops
declarationevents
- an object of events that should be attached to each element, with the same definition as in theevents
declarationinit
- a function that will be run each time an element is created for any one time setup. This is passed the repeated element, the data item, and the index of the item in the sourceitems
array
There is also a repeat
helper for use on the server.
Next: Server Rendering
Previous: Lifecycle