CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-react

React is a JavaScript library for building user interfaces through a declarative, component-based approach.

Pending
Overview
Eval results
Files

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>;

Install with Tessl CLI

npx tessl i tessl/npm-react

docs

built-in-components.md

caching.md

children.md

components.md

composition.md

context.md

development.md

elements.md

experimental.md

hooks-context.md

hooks-effects.md

hooks-imperative.md

hooks-performance.md

hooks-state.md

hooks-transitions.md

index.md

refs.md

transitions.md

tile.json