Skip to content

List Rendering

import { signal, ul, li } from "@whisq/core";
const items = signal(["Apple", "Banana", "Cherry"]);
ul(
() => items.value.map(item => li(item))
)

For large or frequently-changing lists, each() with a key function reuses DOM nodes:

import { signal, each, ul, li, span, button } from "@whisq/core";
const todos = signal([
{ id: 1, text: "Learn Whisq" },
{ id: 2, text: "Build an app" },
]);
ul(
each(() => todos.value, (todo) =>
li(
span(todo.text),
button({ onclick: () => remove(todo.id) }, "x"),
),
{ key: (todo) => todo.id },
),
)
ApproachUse When
.map()Small lists, rarely changing
each() without keyMedium lists, index identity
each() with keyLarge lists, reorderable items
  • Lifecycle — Hooks for mount, cleanup, async data