ctx.libs is the unified namespace for RunJS built-in libraries (React, Ant Design, dayjs, lodash, etc.). No import or async loading; use ctx.libs.xxx directly.
| Scenario | Description |
|---|---|
| JSBlock / JSField / JSItem / JSColumn | React + Ant Design for UI, dayjs for dates, lodash for data |
| Formulas / calculations | formula or math for Excel-like formulas and math expressions |
| Event flow / linkage | lodash, dayjs, formula, etc. in logic-only code |
| Property | Description | Docs |
|---|---|---|
ctx.libs.React | React core for JSX and Hooks | React |
ctx.libs.ReactDOM | ReactDOM (e.g. createRoot) | React DOM |
ctx.libs.antd | Ant Design (Button, Card, Table, Form, Input, Modal, etc.) | Ant Design |
ctx.libs.antdIcons | Ant Design icons (PlusOutlined, UserOutlined, etc.) | @ant-design/icons |
ctx.libs.dayjs | Date/time utilities | dayjs |
ctx.libs.lodash | Utilities (get, set, debounce, etc.) | Lodash |
ctx.libs.formula | Excel-like formulas (SUM, AVERAGE, IF, etc.) | Formula.js |
ctx.libs.math | Math expressions and evaluation | Math.js |
For backward compatibility, some libs are also on ctx: ctx.React, ctx.ReactDOM, ctx.antd, ctx.dayjs. Prefer ctx.libs.xxx for consistency and docs.
lodash, formula, math are lazy-loaded: the first access to ctx.libs.lodash triggers a dynamic import, then the result is cached. React, antd, dayjs, antdIcons are preloaded in context.
ctx.importAsync('react@19'), JSX uses that instance; do not mix with ctx.libs.antd. Load antd for that React version (e.g. ctx.importAsync('antd@5.x'), ctx.importAsync('@ant-design/icons@5.x')).ctx.libs.React or Hooks, run await ctx.importAsync('react@version') so the same React as the page is used.