jsx-runtime.ts

Source

15 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

Reference

fneach<T>(items: T[], render: (item: T, index: number) => JSXNode): JSXNodeMaps over an array and renders each item.

Maps over an array and renders each item.

View source

Parameters

  • items T[]
  • render (item: T, index: number) => JSXNode

Returns

JSXNode

Examples

{each(items, (item) => <li>{item.name}</li>)}
fnescapeHtml(str: string): stringEscapes HTML special characters to prevent XSS.

Escapes HTML special characters to prevent XSS.

View source

Parameters

  • str string

Returns

string
fnFragment({ children }: { children?: JSXChild }): JSXNodeFragment component - renders children without a wrapper element.

Fragment component - renders children without a wrapper element.

View source

Parameters

  • param { ... }

Returns

JSXNode
fnjsx(type: JSXElementType, props: JSXProps, _key?: string): JSXNodeCreates a JSX element. This is the core function called by the JSX transform.

Creates a JSX element. This is the core function called by the JSX transform.

View source

Parameters

  • type JSXElementType
  • props JSXProps
  • _key string

    optional

Returns

JSXNode
typeJSXChild = string | number | boolean | null | undefined | JSXNode | JSXChild[]Valid JSX child types.

Valid JSX child types.

View source

typeJSXElementType = string | ((props: Record<string, unknown>) => JSXNode)JSX element type - either a string (intrinsic) or a function component.

JSX element type - either a string (intrinsic) or a function component.

View source

interfaceJSXNodeJSX node - the result of JSX expressions.

JSX node - the result of JSX expressions.

View source

interfaceJSXPropsProps with children.

Props with children.

View source

fnjsxs(type: JSXElementType, props: JSXProps, key?: string): JSXNodeCreates a JSX element with static children. Called by the JSX transform for ele…

Creates a JSX element with static children. Called by the JSX transform for elements with multiple children.

View source

Parameters

  • type JSXElementType
  • props JSXProps
  • key string

    optional

Returns

JSXNode
fnraw(html: string): JSXNodeCreates raw HTML without escaping. Use with caution - only for trusted content.

Creates raw HTML without escaping. Use with caution - only for trusted content.

View source

Parameters

  • html string

Returns

JSXNode

Examples

<div>{raw('<strong>Bold</strong>')}</div>
fnrenderAttr(name: string, value: unknown): stringRenders an attribute value to a string.

Renders an attribute value to a string.

View source

Parameters

  • name string
  • value unknown

Returns

string
fnrenderChildren(children: JSXChild): stringRenders children to HTML string.

Renders children to HTML string.

View source

Parameters

  • children JSXChild

Returns

string
fnrenderToString(node: JSXNode): stringRenders a JSX node to an HTML string.

Renders a JSX node to an HTML string.

View source

Parameters

  • node JSXNode

Returns

string
fntoHtmlAttr(name: string): stringConverts a camelCase attribute name to kebab-case for HTML. Special handling fo…

Converts a camelCase attribute name to kebab-case for HTML. Special handling for data- and aria- attributes.

View source

Parameters

  • name string

Returns

string
fnwhen(condition: boolean, content: JSXNode): JSXNodeConditionally renders content.

Conditionally renders content.

View source

Parameters

  • condition boolean
  • content JSXNode

Returns

JSXNode

Examples

{when(isLoggedIn, <UserMenu />)}