mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-04 04:23:02 +00:00
17 lines
2.0 KiB
JSON
17 lines
2.0 KiB
JSON
{
|
|
"id": "fe97831963938eb6a767a77c",
|
|
"source": "solid:signals",
|
|
"type": "github-document",
|
|
"title": "index-array",
|
|
"content": "---\ntitle: indexArray\nuse_cases: \u003e-\n rendering lists by index, stable item references, index-based list operations,\n optimized list rendering\ntags:\n - arrays\n - lists\n - index\n - rendering\n - optimization\nversion: '1.0'\ndescription: \u003e-\n Map arrays by index in SolidJS where items are signals and indices are\n constant. Optimized helper for index-based list rendering patterns.\n---\n\n```tsx\nimport { indexArray } from \"solid-js\"\n\nfunction indexArray\u003cT, U\u003e(\n\tlist: () =\u003e readonly T[],\n\tmapFn: (v: () =\u003e T, i: number) =\u003e U\n): () =\u003e U[]\n\n```\n\nSimilar to `mapArray` except it maps by index.\nThe item is a signal and the index is now the constant.\n\nUnderlying helper for the `\u003cIndex\u003e` control flow.\n\n```tsx\nconst mapped = indexArray(source, (model) =\u003e {\n return {\n get id() {\n return model().id\n }\n get firstInitial() {\n return model().firstName[0];\n },\n get fullName() {\n return `${model().firstName} ${model().lastName}`;\n },\n }\n});\n```\n\n## Arguments\n\n| Name | Type | Description |\n| :---- | :----------------------------- | :-------------------- |\n| list | `() =\u003e readonly T[]` | The list to map. |\n| mapFn | `(v: () =\u003e T, i: number) =\u003e U` | The mapping function. |",
|
|
"url": "https://github.com/solidjs/solid-docs/blob/HEAD/src/routes/reference/reactive-utilities/index-array.mdx",
|
|
"metadata": {
|
|
"path": "src/routes/reference/reactive-utilities/index-array.mdx",
|
|
"repo": "solidjs/solid-docs",
|
|
"repo_url": "https://github.com/solidjs/solid-docs.git",
|
|
"size": 1260,
|
|
"source_type": "github"
|
|
},
|
|
"hash": "ef5ba6756bf5eaecada95b45b658f2cc9e9a3ad6245506ae2d4872dc21ef79f3",
|
|
"timestamp": "2026-02-23T11:43:00.189941483+01:00"
|
|
} |