Skip to content

Commit 0a7c278

Browse files
docs: clarify control-flow callback shapes
Document the mode-specific callback signatures for mapArray and For so generated API docs match runtime behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b964dc7 commit 0a7c278

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@solidjs/signals": patch
3+
"solid-js": patch
4+
---
5+
6+
Document the mode-specific callback shapes for mapArray and For.

packages/solid-signals/src/map.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ export type Maybe<T> = T | void | null | undefined | false;
1616

1717
/**
1818
* Reactively maps an array, reusing the previously-mapped value for unchanged
19-
* items. By default, the callback receives the raw row value and a reactive
20-
* index accessor. Index-owned and custom-keyed rows receive accessors where
21-
* the row can be preserved while that argument changes.
19+
* items.
20+
*
21+
* The callback shape follows the keying mode:
22+
* - default / `keyed: true` receives `(item, index)` where `item` is the raw
23+
* row value and `index` is an accessor.
24+
* - `keyed: false` receives `(item, index)` where `item` is an accessor and
25+
* `index` is a stable number.
26+
* - `keyed: item => key` receives accessors for both arguments.
2227
*
2328
* This is the underlying helper that powers `<For>`. App code should use
2429
* `<For>` directly; reach for `mapArray` when implementing custom list

packages/solid/src/client/flow.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ const narrowedError = (name: string) =>
3535
* Receives a map function as its child and returns a JSX element for each
3636
* list item; if the list is empty, an optional `fallback` is rendered instead.
3737
*
38+
* The child callback shape follows the keying mode:
39+
* - default / `keyed={true}` receives `(item, index)` where `item` is the raw
40+
* row value and `index` is an accessor.
41+
* - `keyed={false}` receives `(item, index)` where `item` is an accessor and
42+
* `index` is a stable number.
43+
* - `keyed={(item) => key}` receives accessors for both arguments.
44+
*
3845
* @example
3946
* ```tsx
4047
* <For each={items} fallback={<div>No items</div>}>

packages/solid/src/server/flow.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ type ForOptions<T> = {
3737

3838
/**
3939
* Creates a list of elements from a list
40-
*
4140
* @description https://docs.solidjs.com/reference/components/for
4241
*/
4342
export function For<T extends readonly any[], U extends SolidElement>(props: {

0 commit comments

Comments
 (0)