[]previous and next page

Index

Renders one row per position.

Renders one row per position. Rows are created and removed only when the length changes; the row at position i stays, and its item accessor follows the value at i. Use it for primitive lists where identity does not matter.

Import#

ts
import { Index } from "@shadow-js/web";

Signature#

ts
function Index<T>(props: IndexProps<T>): Accessor<unknown[]>

Parameters#

Name Description
props See IndexProps.

Returns#

An accessor of the row values, in input order.

Examples#

ts
import { useSignal } from "@shadow-js/core";
import { Index } from "@shadow-js/web";

function Cells() {
  const [values] = useSignal([10, 20, 30]);
  return (
    <ul>
      <Index each={values()}>{(value, index) => <li>{`${index}: ${value()}`}</li>}</Index>
    </ul>
  );
}