jsx
JSX support for UI components.
static
jsx(f: string, presets: any, ...rest: any[]): ViewClass
Summary
This function provides support for JSX elements, when used in .jsx or .tsx files. it’s used by the TypeScript compiler (or any other JSX compiler) to convert JSX elements to function calls.
Note
To enable JSX support for TypeScript projects, set thejsxFactoryconfiguration toui.jsx, and importuiin each.tsxfile to allow the compiler to access it.
Bindings in label text — Several JSX elements accept text content, namely <label>, <button>, <toggle>, and <textfield> (for placeholder text). This text is assigned to the text, label, or placeholder properties, and may consist of plain text and bindings (i.e. the result of bound() functions, refer to Binding for more information).
As a shortcut within JSX text content, bindings may also be specified directly using %[...] syntax, which are used with bound.strf(). In addition, this syntax may be used with aliases and default string values:
Foo: %[foo]— inserts a binding forfooFoo: %[foo:.2f]— inserts a binding forfoo, and uses bound.strf() to format the bound value as a number with 2 decimalsFoo: %[foo=somePropertyName]— inserts a binding forsomePropertyName, but allows for localization ofFoo: %[foo]insteadFoo: %[foo=another.propertyName:.2f]— inserts a bindings foranother.propertyName, but allows for localization ofFoo: %[foo:.2f]instead.Foo: %[foo=some.numProp:?||None]— inserts a binding forsome.numProp, but allows for localization ofFoo: %[foo:?||None]instead (and insertsNoneif the value forsome.numPropis undefined or an empty string).
Related
- uiAn object with functions for creating UI components and other resources.
