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
| name | type | description |
|---|---|---|
| items | iterable | () => iterable | array, Set, Map, or a signal returning one of the above |
| callback | (item, index) => JSX.Element | runs once per row; its return value is rendered |
| noSort? | boolean | when true, reordering the input does not reorder the DOM |
| fallback? | any | rendered when the input is empty |
| reactiveIndex? | boolean | when 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