or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

built-in-components.mdcaching.mdchildren.mdcomponents.mdcomposition.mdcontext.mddevelopment.mdelements.mdexperimental.mdhooks-context.mdhooks-effects.mdhooks-imperative.mdhooks-performance.mdhooks-state.mdhooks-transitions.mdindex.mdrefs.mdtransitions.md
tile.json

elements.mddocs/

Element Creation

Rarely used directly (JSX preferred).

createElement

Creates React elements (used by JSX).

function createElement<P>(
  type: string | ComponentType<P>,
  props?: (P & { key?: Key; ref?: Ref<any> }) | null,
  ...children: ReactNode[]
): ReactElement<P>;
createElement('div', { className: 'container' }, 'Hello');
// JSX: <div className="container">Hello</div>

cloneElement

Clone and modify element props.

function cloneElement<P>(
  element: ReactElement<P>,
  props?: Partial<P> & { key?: Key; ref?: Ref<any> },
  ...children: ReactNode[]
): ReactElement<P>;
// Add props to children
<div>
  {Children.map(children, child => cloneElement(child, { className: 'enhanced' }))}
</div>

isValidElement

Type guard for React elements.

function isValidElement(object: any): boolean;
if (isValidElement(content)) {
  return content;
}
return <div>{String(content)}</div>;