all repos — h3 @ ba38ad5b41611b5e2ca05614a0acecfca29350f3

A tiny, extremely minimalist JavaScript microframework.

example/assets/js/components/todoList.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
import h3 from "../h3.js";
import Todo from "./Todo.js";

export default function TodoList() {
  const { page, pagesize } = h3.state();
  const filteredTodos = h3.state('filteredTodos');
  const start = (page - 1) * pagesize;
  const end = Math.min(start + pagesize, filteredTodos.length);
  return h3(
    "div.todo-list",
    filteredTodos.slice(start, end).map(Todo)
  );
}