logologo
Get Started
Tutorials
Guide
Development
Plugins
API
Home
English
简体中文
日本語
한국어
Español
Português
Deutsch
Français
Русский
Get Started
Tutorials
Guide
Development
Plugins
API
Home
logologo
RunJS Overview
Importing Modules
Rendering in Container

Global Variables

window
document
navigator

ctx

ctx.blockModel
ctx.collection
ctx.collectionField
ctx.dataSource
ctx.dataSourceManager
ctx.element
ctx.exit()
ctx.exitAll()
ctx.filterManager
ctx.form
ctx.getModel()
ctx.getValue()
ctx.getVar()
ctx.i18n
ctx.importAsync()
ctx.initResource()
ctx.libs
ctx.location
ctx.logger
ctx.makeResource()
ctx.message
ctx.modal
ctx.model
ctx.notification
ctx.off()
ctx.on()
ctx.openView()
ctx.render()
ctx.request()
ctx.requireAsync()
ctx.resource
ctx.route
ctx.router
ctx.setValue()
ctx.sql
ctx.t()
ctx.view
Previous PageImporting Modules
Next Pagewindow

#In-container Rendering

Use ctx.render() to render content into the current container (ctx.element). It supports the following three forms:

#ctx.render()

#Rendering JSX

ctx.render(<button>Button</button>);

#Rendering DOM Nodes

const div = document.createElement('div');
div.innerHTML = 'Hello World';
ctx.render(div);

#Rendering HTML Strings

ctx.render('<h1>Hello World</h1>');

#JSX Description

RunJS can render JSX directly. You can use the built-in React/component libraries or load external dependencies on demand.

#Using Built-in React and Component Libraries

const { Button } = ctx.libs.antd;

ctx.render(<Button>Click</Button>);

#Using External React and Component Libraries

Load specific versions on demand via ctx.importAsync():

const React = await ctx.importAsync('react@19.2.4');
const { Button } = await ctx.importAsync('antd@6.2.2?bundle');

ctx.render(<Button>Click</Button>);

Suitable for scenarios requiring specific versions or third-party components.

#ctx.element

Not recommended (deprecated):

ctx.element.innerHTML = '<h1>Hello World</h1>';

Recommended way:

ctx.render(<h1>Hello World</h1>);