logo
Zess
Guide
API
Playground
English
简体中文
Guide
API
Playground
English
简体中文
logo
Zess

Getting Started

Introduction
Quick Start

Core

Basic Reactivity
Lifecycle
Components
Reactive Utilities
Store Utilities
Secondary Primitives
Rendering
JSX Attributes

Router

Components
Primitives
📝 Edit this page on GitHub
Previous pageSecondary Primitives
Next pageJSX Attributes

#Rendering

#render

Renders a component into a DOM element. Creates a reactive root and handles mounting and unmounting.

Type:

render(code: Getter<JSX.Element>, el: Element | Document): () => void

Parameters:

  • code: A function that returns the JSX element to render
  • el: The DOM element or document to render into

Returns: A dispose function that cleans up the rendered component

Example:

function App() {
  const [count, setCount] = useSignal(0)
  return (
    <div>
      <p>Count: {count()}</p>
      <button onClick={() => setCount((prev) => prev + 1)}>Increment</button>
    </div>
  )
}

const dispose = render(() => <App />, document.getElementById('app'))

// Later, to unmount and clean up
// dispose()