CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-inferno

An extremely fast, React-like JavaScript library for building modern user interfaces

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

core-rendering.mddocs/

Core Rendering

Main rendering functionality for mounting and updating virtual DOM trees to real DOM elements with high-performance reconciliation.

Capabilities

Render Function

Renders a virtual node tree into a DOM container element.

/**
 * Renders a virtual node tree into a DOM container element
 * @param input - VNode or InfernoNode to render
 * @param parentDOM - DOM element to render into
 * @param callback - Optional callback called after rendering completes
 * @param context - Optional context object passed to components
 */
function render(
  input: VNode | InfernoNode,
  parentDOM: ParentDOM,
  callback?: (() => void) | null,
  context?: ContextObject
): void;

Usage Examples:

import { render, createVNode } from "inferno";

// Basic rendering
const vnode = createVNode(1, 'div', null, 'Hello World');
render(vnode, document.getElementById('app'));

// With callback
render(vnode, document.getElementById('app'), () => {
  console.log('Render complete');
});

// With context
const context = { theme: 'dark' };
render(vnode, document.getElementById('app'), null, context);

Create Renderer

Creates a reusable renderer function bound to a specific DOM container.

/**
 * Creates a reusable renderer function bound to a specific DOM container
 * @param parentDOM - Optional DOM element to bind the renderer to
 * @returns Renderer function for multiple render calls
 */
function createRenderer(parentDOM?: ParentDOM): 
  (lastInput: any, nextInput: any, callback?: any, context?: any) => void;

Usage Examples:

import { createRenderer, createVNode } from "inferno";

// Create bound renderer
const renderer = createRenderer(document.getElementById('app'));

// Use renderer multiple times
renderer(null, createVNode(1, 'div', null, 'First render'));
renderer(lastVNode, createVNode(1, 'div', null, 'Updated content'));

// Create unbound renderer (container passed as first argument)
const unboundRenderer = createRenderer();
unboundRenderer(document.getElementById('app'), createVNode(1, 'h1', null, 'Title'));

Render Internal

Internal rendering implementation used by other inferno packages and advanced use cases.

/**
 * Internal rendering implementation used by other inferno packages
 * @param input - VNode or InfernoNode to render
 * @param parentDOM - DOM element to render into
 * @param callback - Optional callback called after rendering completes
 * @param context - Context object passed to components
 */
function renderInternal(
  input: VNode | InfernoNode,
  parentDOM: ParentDOM,
  callback: (() => void) | null,
  context: ContextObject
): void;

Rendering Process

The rendering process in Inferno follows these steps:

  1. Input Validation: Validates the input VNode and parent DOM element
  2. VNode Preparation: Clones VNodes if they're already in use to prevent conflicts
  3. Mounting/Patching: Either mounts new content or patches existing content
  4. Lifecycle Execution: Calls component lifecycle methods and animation hooks
  5. Callback Execution: Invokes the optional callback after completion

Performance Optimizations

  • VNode Reuse: Clones VNodes that are already in use to enable safe reuse
  • Efficient Patching: Only updates changed parts of the DOM tree
  • Lifecycle Batching: Batches lifecycle calls for better performance
  • Animation Queuing: Efficiently manages animation lifecycle hooks

Error Handling

Common rendering errors and their causes:

  • Invalid Parent DOM: Throws error if parentDOM is null or invalid
  • Document Body Rendering: Development warning when trying to render to document.body
  • VNode Validation: Development-time validation of VNode structure

Context Passing

Context objects are passed down the component tree and available in component constructors and lifecycle methods:

// Parent component sets context
render(vnode, container, null, { theme: 'dark', locale: 'en' });

// Child components access context
class MyComponent extends Component {
  constructor(props, context) {
    super(props, context);
    console.log(context.theme); // 'dark'
  }
}

docs

component-system.md

core-rendering.md

event-handling.md

fragments-utilities.md

index.md

refs.md

vnode-creation.md

tile.json