React / foldkit-react-codegen

Supported Foldkit constructs

Foldkit constructReact output
h.div(attrs, children) / HTML, SVG, MathML tags<div ...>...</div>
h.keyed('li')(key, attrs, children)<li key={key} ...>
h.emptynull
h.submodel({ model, view, toParentMessage })view(model, ..., m => dispatch(toParentMessage(m)))
Submodel.defineView<Model, Message>(...)Compiled view with Model preserved
createLazy() / createKeyedLazy() slotsDirect view(...) call (slot removed)
Custom element spec.withMessage(h)JSX tag with props and on<event> handlers
Class, Id, Key, For, Tabindex, ReadonlyclassName, id, key, htmlFor, tabIndex, readOnly
AriaLabelledBy(x) and Aria*aria-labelledby={x} and matching aria-* props
Attribute('k', v) / DataAttribute('k', v)k={v} / data-k={v}
Style({ 'background-color': c })style={{ backgroundColor: c }}
OnClick(msg) / focus / mouse / OnDoubleClickonClick={() => dispatch(msg)}
OnInput(f)onChange={e => dispatch(f(e.currentTarget.value))}
OnKeyDown(f) / OnKeyUp(f)onKeyDown / onKeyUp with modifier flags
OnKeyDownSelf(f)onKeyDown guarded by target === currentTarget
OnSubmit(msg)onSubmit calling preventDefault() then dispatch
  • Custom elements: React 19 sets properties and attaches on<event> listeners matching CustomEvent.detail. Define custom elements before React renders them, and note the compiler appends a declare module 'react' augmentation typing each tag's props as Record<string, unknown>. Unused local element specs are stripped from generated files.
  • Controlled inputs: OnInput maps intentionally to React's onChange, which fires on every native input event and avoids controlled-input warnings when paired with value.