jac-cl-components

Write client-side Jac UI components with reactive state, JSX rendering, and typed event handlers.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-cl-components-nihalnihalani
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: jac-cl-components
Source: https://github.com/nihalnihalani/jachacks-sf-2026/tree/main/plugins/jac-codex/skills/jac-cl-components
Command: npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-cl-components-nihalnihalani

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing client-side UI in Jac requires translating React habits into Jac syntax, and mistakes like in-place state mutation, stale closures, or misplaced hooks cause silent runtime bugs with no compile errors. This Skill provides the exact rules, patterns, and pitfalls for authoring correct client components in .jac files. ## Core Features & Use Cases - Component authoring rules: Defines component shape (def:pub returning JsxElement), reactive has state, mount effects via can with entry, and typed event handlers (MouseEvent, ChangeEvent, FormEvent). - Props and callbacks: Covers typed props, Callable callback signatures, children defaults, props bundles, and shorthand/spread attribute syntax. - JSX statement slots and pitfalls: Documents expression vs statement slots, skip; semantics, key warnings, and silent-failure bugs like in-place mutation, stale async snapshots, and hook ordering. - Use Case: When building a multi-page Jac web app, use this Skill to write a BookCard component with typed props, a delete callback, and reactive list state that re-renders correctly without React-style useState calls. ## Quick Start Write a Jac client component with a counter button, an input field, and a mount effect following the jac-cl-components conventions.

Frequently Asked Questions about jac-cl-components

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a client component in Jac?▼

Define a `def:pub` function returning `JsxElement` in a `.jac` file with JSX or npm imports. Declare reactive state with `has` fields, mount effects with `async can with entry`, and event handlers as `def` methods typed with DOM events like `MouseEvent`.

How do I use state in Jac instead of React useState?▼

Declare `has count: int = 0;` at component scope and assign directly with `count = count + 1;` to trigger re-renders. Never mutate in place with methods like `append` or item assignment, since React only re-renders on a new value assignment.

Can I import React hooks like useEffect in Jac client code?▼

Jac compiles `can with entry` blocks to `useEffect` automatically, so manual import is rarely needed. For acquire-then-release pairs like intervals, import `useEffect` from react and return a cleanup lambda, since `entry` and `exit` compile to separate closures.

Why is my Jac component not re-rendering after updating a list?▼

In-place mutation such as `todos.append(x)` or `todos[0] = y` does not re-render because React requires a new value. Rebind a fresh list instead, for example `todos = todos + [x];`, so the state assignment triggers an update.

How do I pass callbacks as props to Jac components?▼

Type the prop with `Callable[[str], None]` for a one-string callback and pass it as a JSX attribute like `onDelete={remove}`. Wrap the call in a local handler so parent-side data such as a row id is closed over when the event fires.

Why does my Jac JSX loop fail with a type error?▼

Calling `.map()` on a Jac list fails with E1030; use a statement slot like `{for x in items { <li>{x}</li> }}` instead. Also ensure `has` state is typed with the actual imported node types rather than `list[any]`, which loses element typing.