reatom-jsx
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReatom JSX
Reatom JSX
Use this skill when implementing or explaining . Treat REFERENCE.md as the canonical reference bundled with this skill.
@reatom/jsx当实现或讲解时使用此技能。将REFERENCE.md视为与此技能捆绑的权威参考文档。
@reatom/jsxHow to use
使用方法
- Read the relevant sections of REFERENCE.md — do not assume React/Vue JSX semantics (no virtual DOM, no diffing, no component re-renders).
- For Reatom core (atoms, wrap, async, routing), use the skill.
reatom - For pull requests and skeptic validation, use plus this skill for JSX-specific patterns.
reatom-review
- 阅读REFERENCE.md的相关章节——不要假设遵循React/Vue的JSX语义(无虚拟DOM、无差异对比、无组件重新渲染)。
- 对于Reatom核心功能(atoms、wrap、async、routing),请使用技能。
reatom - 对于拉取请求和严谨验证,请结合使用与本技能来处理JSX特定模式。
reatom-review
Section map
章节映射
Use this map to open only the relevant parts of REFERENCE.md:
| Topic | Section |
|---|---|
| Install, tsconfig, Vite | Installation, Framework compatibility |
| Bootstrapping the app | Example, Hot module replacement |
| Props, children, bindings | Reference → Props, Children, Models |
| Inline and css-prop styles | Reference → |
| Class names | Reference → |
| Components and lists | Reference → Components |
| Bulk prop binding | Reference → |
| SVG and raw markup | Reference → SVG |
| Mount side effects | Reference → |
| Errors, boundaries, jsxError | Error handling |
| Utilities | Utilities → |
| TypeScript | TypeScript |
| SSR and keyed lists | Limitations |
使用此映射仅打开REFERENCE.md的相关部分:
| 主题 | 章节 |
|---|---|
| 安装、tsconfig、Vite | Installation, Framework compatibility |
| 应用引导 | Example, Hot module replacement |
| Props、子元素、绑定 | Reference → Props, Children, Models |
| 内联样式与css-prop样式 | Reference → |
| 类名 | Reference → |
| 组件与列表 | Reference → Components |
| 批量props绑定 | Reference → |
| SVG与原始标记 | Reference → SVG |
| 挂载副作用 | Reference → |
| 错误、边界、jsxError | Error handling |
| 工具类 | Utilities → |
| TypeScript | TypeScript |
| SSR与键列表 | Limitations |
Implementation defaults
实现默认规则
- Components are plain functions evaluated once at mount; use atoms and reactive props for updates.
- Reads: zero-arg atom call. Writes: .
.set(...) - handlers that touch Reatom state are wrapped automatically; do not wrap manually in JSX.
on:* - Never reuse a JSX element instance in multiple places — call the component function or factory each time.
- Plain writable atoms: /
model:valuefor search, toggles, linked-list row atoms.model:checked - Real forms: from
reatomFormwith@reatom/coreand<form model={form}>— nevermodel:field={form.fields.x}on field atoms (bypassesmodel:value).field.change - Form submit loader: style on the form (set automatically by
[data-submitting]); CSS-only spinner onmodel={form}.[type='submit']::after - For SPA navigation use : links via
reatomRoute, programmatic moves viahref={route.path(params)}— see theroute.go(params)skill Routing section.reatom - Use for DOM properties,
prop:*for attributes when semantics matter.attr:* - Mount with ; call
mount(root, <App />)on teardown (including Vite HMR). Preferunmount()(@reatom/viteplugin) so mount/route HMR dispose is automatic.reatom() - For dynamic lists, store elements in atoms or map inside reactive children — no keyed reconciliation.
- Isolate UI failures with and lazy children
<ErrorBoundary fallback={...}>; track globally via{() => <Child />}/jsxError.addCallHook(jsxError, ...)
When REFERENCE.md and local examples disagree, prefer the reference and fix the example if it is wrong.
- 组件是挂载时仅执行一次的普通函数;使用atoms和响应式props进行更新。
- 读取:无参数atom调用。写入:。
.set(...) - 涉及Reatom状态的处理程序会自动被包装;无需在JSX中手动包装。
on:* - 切勿在多个位置复用JSX元素实例——每次都要调用组件函数或工厂方法。
- 普通可写atoms:/
model:value用于搜索、切换、链表行atoms。model:checked - 实际表单:使用中的
@reatom/core,配合reatomForm和<form model={form}>——切勿在字段atoms上使用model:field={form.fields.x}(会绕过model:value)。field.change - 表单提交加载器:为表单设置样式(由
[data-submitting]自动设置);在model={form}上使用纯CSS加载动画。[type='submit']::after - 单页应用导航使用:通过
reatomRoute创建链接,通过href={route.path(params)}进行程序化跳转——请查看route.go(params)技能的路由章节。reatom - 当语义重要时,使用处理DOM属性,使用
prop:*处理HTML属性。attr:* - 使用进行挂载;在销毁时调用
mount(root, <App />)(包括Vite热模块替换)。推荐使用unmount()(@reatom/vite插件),这样挂载/路由的热模块替换清理会自动进行。reatom() - 对于动态列表,将元素存储在atoms中或在响应式子元素内进行映射——无需键控协调。
- 使用和惰性子元素
<ErrorBoundary fallback={...}>隔离UI故障;通过{() => <Child />}/jsxError进行全局追踪。addCallHook(jsxError, ...)
当REFERENCE.md与本地示例不一致时,优先参考权威文档,并在示例错误时进行修正。