Skip to content

Demonstrate direct Preact rendering - #41

Open
cowboyd wants to merge 1 commit into
mainfrom
dom-preact
Open

cowboyd wants to merge 1 commit into
mainfrom
dom-preact

Conversation

@cowboyd

@cowboyd cowboyd commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Demonstrate Preact 11 rendering directly into Clack elements through Preact's own render() and JSX runtime.

Key to note is the fact that there is zero custom integration code for @clack/ui and preact. Preact just renders right into our UI with no adaptation.

import { useEffect, useState } from 'preact/hooks';
import { greetingFrames } from './animation.ts';

export function Greeting() {
	const [text, setText] = useState('Hello World!');

	useEffect(() => {
		const animation = greetingFrames();
		let timer: ReturnType<typeof setTimeout>;

		function advance() {
			const frame = animation.next().value;
			setText(frame.text);
			timer = setTimeout(advance, frame.delay);
		}

		advance();
		return () => clearTimeout(timer);
	}, []);

	return <span>{text}</span>;
}
2026-11-12 13 48 03

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • All tests pass (pnpm test)
  • Files are formatted (pnpm format)
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants