File tree Expand file tree Collapse file tree
src/routes/reference/reactive-utilities Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ Mapping function for each item.
5555
5656- ** Type:** ` () => any `
5757
58- Fallback accessor used when the source array is empty or falsy.
58+ Fallback accessor used when the source array is empty or falsy. The mapped result becomes a single fallback entry.
5959
6060## Return value
6161
@@ -67,8 +67,8 @@ Returns an accessor for the mapped array.
6767
6868- Items are cached by value identity.
6969- The index argument is an accessor.
70- - ` mapFn ` is not a tracking scope.
71- - Reordering reuses existing mapped items when their source values are retained .
70+ - ` mapFn ` is not a tracking scope, so reads inside the callback do not track unless they happen inside nested JSX or another reactive scope .
71+ - Reordering reuses existing mapped items for retained source values and updates their index accessors .
7272- This is the underlying helper for [ ` <For> ` ] ( /reference/components/for ) .
7373
7474## Examples
@@ -79,14 +79,14 @@ Returns an accessor for the mapped array.
7979import { createSignal , mapArray } from " solid-js" ;
8080
8181const [source] = createSignal ([
82- { id: 1 , name : " A " },
83- { id: 2 , name : " B " },
82+ { id: 1 , status : " pending " },
83+ { id: 2 , status : " done " },
8484]);
8585
8686const mapped = mapArray (source , (item , index ) => ({
8787 id: item .id ,
88- name : item .name ,
89- position: index ,
88+ status : item .status ,
89+ position : () => index () ,
9090}));
9191```
9292
You can’t perform that action at this time.
0 commit comments