indexArray
Edit this pageSolid 2.0 —
The <Index> component has been removed. Use <For keyed={false}> instead. indexArray remains as a low-level utility for index-based mapping where the item is a signal and the index is constant.
import { indexArray } from "solid-js"
function indexArray<T, U>( list: () => readonly T[], mapFn: (v: () => T, i: number) => U): () => U[]Similar to mapArray except it maps by index.
The item is a signal and the index is now the constant.
This is the underlying helper for <For keyed={false}>.
const mapped = indexArray(source, (model) => { return { get id() { return model().id }, get firstInitial() { return model().firstName[0]; }, get fullName() { return `${model().firstName} ${model().lastName}`; }, }});Arguments
| Name | Type | Description |
|---|---|---|
| list | () => readonly T[] | The list to map. |
| mapFn | (v: () => T, i: number) => U | The mapping function. |