Chapter I · The interface

Ajo

State is just a variable.

A small UI library built on JSX and JavaScript generators. A stateful component is a generator: what you declare before its loop persists, and this.next() renders it again. No hooks, no dependency arrays, no rules about call order.

A paper kite shaped like an application window, flying over a dune by the sea.A paper kite shaped like an application window, flying over a dune by the sea.

What Ajo gives you

In practice

clock.tsx

Status Published on npm.

  • ajo 0.2.0

    Generator components, in-place DOM reconciliation and server rendering.

  • ajo-cloves 0.2.1

    Reusable behaviors: controlled state, dismissal, keyboard focus and sensors.

  • ajo-ui 0.3.0

    Unstyled, accessible component families with stable styling hooks.

  • ajo-ui-playa 0.3.0

    Themed components and a build-time UnoCSS preset.

clock.tsx
import type { Stateful } from 'ajo'

export const Clock: Stateful = function* () {
  let now = new Date()

  const timer = setInterval(() => this.next(() => now = new Date()), 1000)
  this.signal.addEventListener('abort', () => clearInterval(timer))

  while (true) yield <time>{now.toLocaleTimeString()}</time>
}