v0.20.230 - 6.4 / 5.9

map

Reactive equivalent of array.map. Runs the callback only for added, removed or changed entries — existing rows keep their state instead of being recreated on every change. Powers <For/> and works with arrays, sets and maps.

Plain array.map(item => <li>{item}</li>) can't react to mutations without rebuilding every row from scratch, losing focus, DOM state, and any work the row performed. map avoids that by keying rows by identity and reusing them across updates.

# Arguments

nametypedescription
itemsiterable | () => iterablearray, Set, Map, or a signal returning one of the above
callback(item, index) => JSX.Elementruns once per row; its return value is rendered
noSort?booleanwhen true, reordering the input does not reorder the DOM
fallback?anyrendered when the input is empty
reactiveIndex?booleanwhen true, index is a signal instead of a number

# map test

Modifying an array and getting reactive changes

# map types

map works with Array, Set and Map