React / foldkit-react-codegen
Supported Foldkit constructs
| Foldkit construct | React output |
|---|---|
h.div(attrs, children) / HTML, SVG, MathML tags | <div ...>...</div> |
h.keyed('li')(key, attrs, children) | <li key={key} ...> |
h.empty | null |
h.submodel({ model, view, toParentMessage }) | view(model, ..., m => dispatch(toParentMessage(m))) |
Submodel.defineView<Model, Message>(...) | Compiled view with Model preserved |
createLazy() / createKeyedLazy() slots | Direct view(...) call (slot removed) |
Custom element spec.withMessage(h) | JSX tag with props and on<event> handlers |
Class, Id, Key, For, Tabindex, Readonly | className, 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 / OnDoubleClick | onClick={() => 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 matchingCustomEvent.detail. Define custom elements before React renders them, and note the compiler appends adeclare module 'react'augmentation typing each tag's props asRecord<string, unknown>. Unused local element specs are stripped from generated files. - Controlled inputs:
OnInputmaps intentionally to React'sonChange, which fires on every nativeinputevent and avoids controlled-input warnings when paired withvalue.