An extremely fast, React-like JavaScript library for building modern user interfaces
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Main rendering functionality for mounting and updating virtual DOM trees to real DOM elements with high-performance reconciliation.
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);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'));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;The rendering process in Inferno follows these steps:
Common rendering errors and their causes:
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'
}
}