Index
Non-keyed list iteration (rendered nodes are keyed to an array index). This is useful when there is no conceptual key, like if the data consists of primitives and it is the index that is fixed rather than the value.
1 2 3 4 5 |
|
A super simple implementation of this component might look like this:
1 2 3 4 5 6 7 8 9 10 |
|
Here's a look at the implementation of the Index
component in Solid:
1 2 3 |
|
Notice that the item is a signal unlike the For
component. This is because the Index
component is not keyed to the item itself but rather the index.
Optional second argument is an index number:
1 2 3 4 5 6 7 |
|
Props¶
Name | Type | Description |
---|---|---|
each | readonly T[] | The array to iterate over. |
fallback | JSX.Element | Optional fallback element to render while the array is loading. |
children | (item: () => T, index: number) => U | The function that renders the children. |