jsx-runtime.ts
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.
Parameters
-
itemsT[] -
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.
fnFragment({ children }: { children?: JSXChild }): JSXNodeFragment component - renders children without a wrapper element.
Fragment component - renders children without a wrapper element.
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.
Parameters
-
typeJSXElementType -
propsJSXProps -
_keystringoptional
Returns
JSXNode
typeJSXChild = string | number | boolean | null | undefined | JSXNode | JSXChild[]Valid JSX child types.
Valid JSX child types.
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.
interfaceJSXNodeJSX node - the result of JSX expressions.
JSX node - the result of JSX expressions.
interfaceJSXPropsProps with children.
Props with children.
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.
Parameters
-
typeJSXElementType -
propsJSXProps -
keystringoptional
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.
Parameters
-
htmlstring
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.
Parameters
-
namestring -
valueunknown
Returns
string
fnrenderChildren(children: JSXChild): stringRenders children to HTML string.
fnrenderToString(node: JSXNode): stringRenders a JSX node to an HTML 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.
Parameters
-
namestring
Returns
string
fnwhen(condition: boolean, content: JSXNode): JSXNodeConditionally renders content.
Conditionally renders content.
Parameters
-
conditionboolean -
contentJSXNode
Returns
JSXNode
Examples
{when(isLoggedIn, <UserMenu />)}