Skip to content

Commit 8253297

Browse files
committed
update
1 parent cd3aa56 commit 8253297

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/routes/reference/reactive-utilities/map-array.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff 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.
7979
import { createSignal, mapArray } from "solid-js";
8080

8181
const [source] = createSignal([
82-
{ id: 1, name: "A" },
83-
{ id: 2, name: "B" },
82+
{ id: 1, status: "pending" },
83+
{ id: 2, status: "done" },
8484
]);
8585

8686
const 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

0 commit comments

Comments
 (0)